Why the name 'Request' does not exist when writing in a class.cs file?

后端 未结 2 1228
北恋
北恋 2021-02-12 12:48

I would like to move the following piece of code from a c# aspx.cs file into a stand alone class.cs file.

string getIP = Request.ServerVariables[\"HTTP_X_FORWARD         


        
2条回答
  •  情歌与酒
    2021-02-12 13:34

    The reason it doesn't work is because you cannot access server variables in a class library project.

    You should avoid attempting to make this act like a web class and instead pass the information you need to the class object via a normal parameter.

提交回复
热议问题