ASP. NET MVC2

Source: Internet
Author: User

Because the controller is placed in the class library in the mvc2 project, the xml file must be parsed. The project structure is as follows:

How can I obtain the absolute path of the xml file in the class library? I searched the internet.

Appdomain. currentdomain. basedirectory obtains the base Directory of the current application domain through this method.

Can I get it through server. mappath ()?

First, I referenced system. web. mvc in the class library, and then the server in the controller class can write it out, but the mappath cannot be clicked. Then I write it myself, and an error is returned.

Error 1 type "system. web. https tutorial erverutilitybase" is defined in the unreferenced assembly. You must add references to the assembly "system. web. abstractions, version = 3.5.0.0, culture = neutral, publickeytoken = 31bf3856ad364e35.

Error 2 "system. web. httpserverutilitybase does not contain the mappath definition, and the acceptable type "system." cannot be found. web. the Extension Method "mappath" for the first parameter of httpserverutilitybase (is there a lack of using commands or assembly references ?)

This error is obvious. Haha immediately introduced system. web. abstractions

String xmlpath = this. server. mappath ("/files/xml/city. xml ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.