Reputation: 2752
I'm using MVC.I want to save xml file inside the services class. so wrote this one.
string path = HttpContext.Current.Server.MapPath((Url.Content("~/client-authentication.xml")));
but there is error and it says
'System.Security.Policy.Url' does not contain a definition for 'Content'
How to solve it?? How can I give the path??
Upvotes: 0
Views: 2427
Reputation: 3637
Is this code in your view(.cshtml) or controller(.cs)?
if cshtml, you can write "string path = Url.Content(...)" directly, no need Server.MapPath.
if controller, just Server.MapPath(...), no need Url.Content.
PS, you can also use AppDomain.CurrentDomain.BaseDirectory to retrive physical path of your site root.
Upvotes: 3
Reputation: 107247
This is the wrong Url
class. You want the System.MVC.Web.UrlHelper instance called Url which is a property provided on MVC controllers.
Upvotes: 1