global-asax

System.EnterpriseServices.Wrapper.dll error

隐身守侯 提交于 2019-11-29 03:47:49
Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. Parser Error Message: Could not load file or assembly 'System.EnterpriseServices.Wrapper.dll' or one of its dependencies. (Exception from HRESULT: 0x800700C1) Source Error: Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="PMP.MvcApplication" Language="C#" %> Yesterday, I shut up my Windows 7, an Windows update was pending there without any process for nearly one hour, then

BeginRequest-like filter in MVC 3?

走远了吗. 提交于 2019-11-29 02:35:12
问题 I have some code in my application that I need to execute on every request, before anything else executes (even before authentication). So far I've been using the Application_BeginRequest event in my Global.asax, and this has worked fine. But this code needs to hit the database, and doing this from Global.asax doesn't feel right for some reason. Also, the Ninject.MVC3 nuget I'm using won't inject dependencies into my HttpApplication ctor. So what I decided to do is move this code into its own

Global 301 redirection from domain to www.domain

梦想与她 提交于 2019-11-29 02:26:18
could i use the begin request of Global.asax to redirect everything, from mydomain.domain to www.mydomain.domain ? If this one is true, how can i do that? protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e) { string currentUrl = HttpContext.Current.Request.Path.ToLower(); if(currentUrl.StartsWith("http://mydomain")) { Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", currentUrl.Replace("http://mydomain", "http://www.mydomain")); Response.End(); } } A couple of minor changes to Jan's answer got it working for me: protected void Application

How to catch HttpRequestValidationException in production

本小妞迷上赌 提交于 2019-11-29 01:15:20
I have this piece of code to handle the HttpRequestValidationException in my global.asax.cs file. protected void Application_Error(object sender, EventArgs e) { var context = HttpContext.Current; var exception = context.Server.GetLastError(); if (exception is HttpRequestValidationException) { Response.Clear(); Response.StatusCode = 200; Response.Write(@"<html><head></head><body>hello</body></html>"); Response.End(); return; } } If I debug my webapplication, it works perfect. But when i put it on our production-server, the server ignores it and generate the " a potentially dangerous request

Parser Error Message: Could not load type 'sometype'

跟風遠走 提交于 2019-11-29 01:09:06
I am experiencing an error that I am unable to resolve for some time now. I was wondering if someone can help identify the cause of this error? I am completely new to asp / asax. After some research, I think that the error I am getting is due to the web application trying to use outdated code. I was thinking to rebuild the c# file using Visual Studio and/or the entire project. However, I am completely new to C# and asp, and was wondering can give me some suggestions if this may fix the problem and/or if there is an possible alternate solution. Error message Parser Error Message: Could not load

what alternatives are there to using global.asax?

风流意气都作罢 提交于 2019-11-29 00:25:45
I am using my own custom authentication with IIS, and I want the server on every page load (no matter what type of file) to first check the Application variable to see if the user is authenticated and authorized to see the site. In global.asax this could be: void Application_Start(Object Sender, EventArgs e) { if(Application["username"] == null) { Response.redirect("login.aspx"); } } The problem is that this site has multiple sub-roots. That is, http://example.com/site1 is a completely different website from http://example.com/site2 . Therefore, I would like said Application_Start function to

Set session variable in Application_BeginRequest

夙愿已清 提交于 2019-11-28 22:26:31
I'm using ASP.NET MVC and I need to set a session variable at Application_BeginRequest . The problem is that at this point the object HttpContext.Current.Session is always null . protected void Application_BeginRequest(Object sender, EventArgs e) { if (HttpContext.Current.Session != null) { //this code is never executed, current session is always null HttpContext.Current.Session.Add("__MySessionVariable", new object()); } } Pankaj Try AcquireRequestState in Global.asax. Session is available in this event which fires for each request: void Application_AcquireRequestState(object sender,

ASP.NET 2.0 : Best Practice for writing Error Page

青春壹個敷衍的年華 提交于 2019-11-28 18:03:45
In asp.net 2.0 web site, what is the best way of writing Error page. I have seen following section at following location: Web.Config <customErrors mode="RemoteOnly" defaultRedirect="~/Pages/Common/DefaultRedirectErrorPage.aspx"> Global.asax void Application_Error(object sender, EventArgs e) { } I am not getting how to use both of them in best way for Error handling. Please guide me best approach. In my global asax i always check to see what type of http error it is... then transfer to the correct error page specified in web.config I like to handle the usual suspects, 404 ( lost page ) and 500

Global.asax is not publishing and event are not firing in Global.asax

若如初见. 提交于 2019-11-28 12:49:04
I am developing ASP.NET web application and for unhandled exception i am making use of Global.asax file Where I wrote a logic to write the error logs as Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) 'Code that runs when an unhandled error occurs End Sub It all works locally but when published the website global.asax not being published still i uploaded global.asax to remote server but events are not firing My application uses IIS 7 as a Web server Do i need any sort of configuration Suggest if you have any solution i also uploaded App_global.asax.compiled and it works

Asp.net System.Web.HttpContext.Current.Session null in global.asax

若如初见. 提交于 2019-11-28 10:55:25
I have a custom security principal object which I set in the global.asax for the current thread and all is well, no problems normally. However, I'm just adding a dynamic image feature by having a page serve up the image and whenever that dynamic image page is loaded the System.Web.HttpContext.Current.Session is null in global.asax which prevents me from setting the security principal as normal and cascading problems from that point onwards. Normally the Session is null in global.asax only once during a session at the start when the user logs in, afterwards it's always available with this