How do I access global variables in App_Code directory in ASP.NET Web Application?
This is my static class for global variables that I have in my App_Code directory:
using System;
public static class GlobalUserInfo
{
public static string Name {get; set;}
public static string Email {get; set;}
public static string Gravatar {get; set;}
}
In my master page cs file (MasterPage.master.cs) I have this page load function:
protected void Page_Load(object sender, EventArgs e)
{
GlobalUserInfo.Email = Request.Form["email"];
GlobalUserInfo.Name = Request.Form["name"];
}
Accessing the data members GlobalUserInfo.Email and GlobalUserInfo.Name like this in Page Load is throwing a Build exception when I try to run it. Commenting out those two lines fixes it. Am I implementing this wrong somehow? I know there isn't a problem with the form request, because inserting the code "string email = Request.Form["email"];" doesn't throw an exception. Any ideas? I'm building and running this in MonoDevel开发者_运维知识库op on Linux, by the way.
精彩评论