HttpContext related errror-message

Posted by Riyu under C# on 4/1/2010 | Views : 1663 | Status : [Member] | Replies : 0
I have created an object of HttpContext and assigned current context value in a class file memberinfo.cs.In next step ,i declared a string object and tried to assign value as shown below:

public class member
#region "variable and declaration"
private HttpContext _context = HttpContext.Current;
private string mykey=_context.Application["key"];

In global.asax file

void Application_Start(Object sender,EventArgs e)
Application["key"] = "JED";
HttpContext context=HttpContext.Current;


after declaring string mykey & when I tried to write _context.Application[""] ,_context is not visible in Intellicense & error message I got is

"Error A field initializer cannot reference the non-static field, method, or property 'WebApplication.memberinfo._context' "

Can any one why I m getting this error & suggest any other way to call context object while assigning.


(No response found.)

Login to post response