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 ");