Question

I am working on a mailSender Class. I can't use the Server.MapPath method from the System.Web.UI Namespace. What reference should i set to make this work? I have referenced to the System / System.Web / System.Web.UI.

This is the msdn i have checked.

Was it helpful?

Solution

Please read TaylorMichaelL answer on this page: The name 'Server' does not exist in the current context. This should help you.

A better approach though is that you add the target folder as a method argument and create the path from that. That way, the class will be usable in non-web contexts as well.

OTHER TIPS

For people that will encounter this problem i will answer my own question so they don't have to follow links to other websites. If you want to use the Server.Mappath, you won't be able to do this when using a DAL or BL. You can gain access to these objects (assuming they are available at the time given that they are contextual) by using the HttpContext.Current property. This property gives you the current context. However you are now trying your DAL/BL to ASP.NET. So what you could do to fix this issue is getting the Server.Mappath on a place where it is contextual, like in your Code Behind.

GL!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top