We have an ASP.Net webform(s) at work which is used for HR purposes. When the form was initially set-up there were no user restrictions set-up as to who could/couldnot have access to what form. A work-around implemented was that frmPrivateData would capture the user name of each person who accessed it and send to an access database, then if in that access database the user name should not have access and email was fired off stating the date/time the user accessed the page.
My question is, how in C# can you capture the name of the web form that is being accessed?
Loading
AnkurPosted Jan 29, 2013, 1:35 AM
i think following code might help you:
string Path = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
System.IO.FileInfo fileInfo = new System.IO.FileInfo(Path);
string PageName = fileInfo.Name;
Thanks..
richard smithPosted Jan 28, 2013, 9:11 AM
AnkurPosted Jan 28, 2013, 4:52 AM
if my understanding with you problem is correct then below is what you need:
in C# application there is a Global.asax.cs file (usually placed in "App_Code"):
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{
//this is the method which gets called on every webform request
// Check that the request has been authenticated
if (!Request.IsAuthenticated)
{
//here your code goes
}
}
hope that helps.
thanks...