Because the controller is placed in the class library in the MVC2 project, the parsing XML file is used, and the project structure is shown below
How to get the absolute path to the XML file in the class library, I searched the web
This method is used by Appdomain.currentdomain.basedirectory to get the base directory of the current application domain
Can you get it through Server.MapPath (), think about it and move your hands immediately.
First I referenced the SYSTEM.WEB.MVC in the class library and then in the Controller Class Server can write out, but MapPath not to come out, I wrote it on my own, the results reported a mistake
Error 1 Type "System.web.https tutorial Erverutilitybase" is defined in an assembly that is not referenced. You must add a reference to the assembly "System.web.abstractions, version=3.5.0.0, Culture=neutral, publickeytoken=31bf3856ad364e35".
Error 2 "System.web.httpserverutilitybase" does not contain the definition of "MapPath" and cannot find an extension method that accepts the first argument of type "System.web.httpserverutilitybase" MapPath "(is missing a using directive or an assembly reference?)
This error is obvious, haha immediately introduced system.web.abstractions
String xmlpath= this.server.mappath ("/files/xml/city.xml");