I have several ASP.NET websites in a solution along with a common C# code project. Something as follows:
Website1
Website2
...
Website(n)
Common
First off I want to use a Global.asax file to log all unhandled exceptions. I could have one Global.aspx file per website but all the code will be the same and it seems pointless having to k...
Hi
I'd like to use the netTcpBinding for my WCF application which is currently hosted in IIS7, which means configuring it to use WAS instead. This is fairly straight forward however, my application previously made use of the Application_Start event in the global.asax file. I do not require access to the httpContext(which I understand ac...
I look for HttpExceptions in the Application_Error sub of my global.asx
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim ex As Exception = HttpContext.Current.Server.GetLastError()
If ex IsNot Nothing Then
If TypeOf (ex) Is HttpUnhandledException Then
If ex.InnerExcept...
We are trying to remove the global.asax from our many web applications in favor of HttpModules that are in a common code base. This works really well for many application events such as BeginRequest and PostAuthentication, but there is no Application Start event exposed in the HttpModule.
I can think of a couple of smelly ways to overc...
Normally I just redirect to a custom error page in on the Application_Error event, but I have a specific error for which I'd like to display an alert message while the user is still on the page which triggers the error. How can I make this happen?
I'm open to a modalpopup or any other type of error message, I just want to ensure the us...
I have a class that returns parameters I've set in the profile properties in web.config. It works great on classes, but I cannot seem to make it work under the Global.asax?
Here is how I get the parameter:
public static string MissingPagePath
{
get { return HttpContext.Current.Profile.GetPropertyValue("MissingPage").ToString(); }
}...
I have a complex URL rewriting scheme which breaks the built in Forms Authentication ReturnUrl mechanism. I would like to grab the requested URL for later redirection away from my login.aspx. I can get this URL in Application_BeginRequest via HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath. However, Session state is not a...
So we're having some issues deploying an ASP.NET MVC app to a client site. Basically when we try to test the app from localhost, we get the dreaded Global.asax parser error indicating it could not load the application global.
Research indicates there are basically 4 possible reasons for this exception we're seeing:
The solution hasn'...
Whenever an unhandled exception occurs on our site, I want to:
Send a notification email
Clear the user's session
Send the user to a error page ("Sorry, a problem occurred...")
The first and last I've had working for a long time but the second is causing me some issues. My Global.asax.vb includes:
Sub Application_Error(ByVal sender...
Hello,
HttpContext.Current.Request.IsLocal is not available in Global.Asax/Application_Start (Request is not available in the context).
How else could I safely determine if my ASP.NET MVC application is started locally or not?
This is to rewrite my web.config conditionally (depending on whether the application is deployed (remote) or ...
In my Global.ASAX file i have the following:
void Session_End(object sender, EventArgs e)
{
System.Web.HttpCookie isAccess = new System.Web.HttpCookie("IsAccess");
isAccess.Expires = DateTime.Now.AddDays(-1);
isAccess.Value = "";
System.Web.HttpContext.Current.Response.Cookies.Add(isAccess);
}
So every time this meth...
the code to strip /Default.aspx and //www is not working (as expected):
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext context = HttpContext.Current;
string url = context.Request.RawUrl.ToString();
bool doRedirect = false;
// remove > default.as...
I've a legacy application using Asp.Net WebSite (winforms...) and I need run a background thread that collect periodically some files.
But this thread must run just one time!
My problem start when I put a method in Application_Start:
void Application_Start(object sender, EventArgs e) {
SetConnection();
SetNHibernate();
SetN...
I have successfully created an iHttpModule to replace my Global.asax file in many Web Forms applications. But in looking at the Global.asax file in my MVC application, the methods are totally different.
I'm wondering if it is still possible to create this same thing in an MVC app. I know it's not necessary and the Global.asax works ju...
I'm trying to get a property (ImpersonatePersonId) from a page in global.asax but get a HttpException saying 'Request is not available in this context'.
I've been searching for some documentation on where in the pipeline the request is accessible, but as far as I can see all Microsoft can produce of documentation is one-liners like "P...
I'm trying to delete files created by current user when he/she clicks logout button
Protected Sub OnLoggingOut(ByVal sender As Object, ByVal e As EventArgs) Handles LoginStatus1.LoggingOut
Try
Dim folder As String = Server.MapPath("~/uploads/")
Dim files As String() = Directory.GetFiles(folder)
...
I'm trying to get a reference to the user object in my Global.asax file's Application_BeginRequest. I'm using the property Context.User but I get a NullReferenceException. Is it possible to get a user object reference in Application_BeginRequest?
...
In which part of the Global.asax lifecycle can I safely 'use' the User object? I'm using the default forms authentication and noticed the following:
Sub Application_BeginRequest()
'Context.User Is Nothing
End Sub
Sub Application_AuthenticateRequest()
'Context.User Is Nothing
End Sub
Sub Application_AuthorizeRequest()
'Cont...
I'm using Forms authentication on my MVC website. I administrate users and roles using the default ASP.NET Configuration option in Visual Studio. All good so far.
I can successfully do Page.User.IsInRole("Moderator") in a View. True is returned as expected.
However when calling Context.User.IsInRole("Moderator") inside Global.asax's Ap...
I am using Visual Studio 2005, and running my application from inside it, directly using its development application server.
If I set a breakpoint inside Application_Start and one inside Session_Start, the latter is reached first, and I honestly think it should be the other way around.
Any thoughts?
...