Monday, August 31, 2015

ASP.NET MVC HttpContext.Current.Server.MapPath null for WCF Webservice

Hi,

Just solved a problem at work:

If HttpContext.Current.Server.MapPath is giving you null or an exception or not working, there are several possibilities. One of them is you didn't enable asp.net compatibility mode.

https://msdn.microsoft.com/en-us/library/aa702682(v=vs.110).aspx

Better off to migrate to another way of finding the server path than depending on HttpContext though,

http://stackoverflow.com/a/6861451

HttpContext is bad to depend on, when dealing with WCF or non-MVC applications (there isn't always a context.)

Hope this helps someone

~ B

5 comments:

  1. this is an important article to read for all the programmers, i think. because it enlists all the points and importance of being a programmar. keep at it, and dont stop posting more

    ReplyDelete
  2. Expand Business Internationally with Business Mergers or Business Contract

    ReplyDelete
  3. Avlite Systems has an industry-leading portfolio of rugged, reliable and patented Aviation lighting products for Aviation, Helipads, Runway, obstruction and Airports lighting

    ReplyDelete