I have a C# Model Class where I am trying to access a .cshtml
page which is supposed to be an email format template. I'm using the following code:
string body = string.Empty;
using (StreamReader reader = new StreamReader(Server.MapPath("~/EmailConfTemplate.cshtml")))
{
body = reader.ReadToEnd();
}
But i am getting the following error message:
The name Server does not exist in the current context
Is there any error in the code or the Server
class can't be accessed in POCO class. Please help.
To execute it inside a .Net pipeline, you can find it as an instance present in HttpContext
System.Web.HttpContext.Current.Server.MapPath()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With