using server.mappath() in an generic handler (.ashx)

Working on a project over the weekend that used a generic handler for some AJAX calls.  In one of the calls I need to map to a local file to great a T4 template file.

In an MVC file you can get away with:

Server.MapPath("~/"), @"App_Data\SomeT4File.txt")

For a generic handler you need to simply change it to the following

HttpContext.Current.Server.MapPath("~/"), @"App_Data\SomeT4File.txt")

 

Advertisements
This entry was posted in Web and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s