global-asax

<machineKey decryptionKey=“AutoGenerate”… being ignored by IIS. Won't invalidate previous session's cookies

℡╲_俬逩灬. 提交于 2019-12-05 21:12:10
问题 (See question below for more context): Are there any situations in which <machineKey validationKey="AutoGenerate,IsolateApps" decryptionKey="AutoGenerate,IsolateApps"/> in web.config would fail to AutoGenerate a new machineKey on App Pool recycle? This is the behavior I'm seeing... I'm using standard ASP.NET FormsAuthentication in an MVC app. If I log a user in using FormsAuthentication.GetAuthCookie and don't use a persistent cookie (relying on the browser's session to remember my authorized

Error executing child request for

安稳与你 提交于 2019-12-05 19:53:49
In my MVC3 application I'm getting the above mention error when I try to handle a maximum request exceeded error. I'm handling the exception at the application level. I'm trying to redirect to an error page that's located in the Shared folder of the views. I'm using the code below to redirect to an error page if the request size is over the limit. this.Server.ClearError(); this.Server.Transfer("~/Views/Shared/NotAuthorised.cshtml"); This is the error im getting. Error executing child request for /SiteName/Views/Shared/NotAuthorised.cshtml According to the Microsoft documentation ( Error

asp.net mvc and check for if a user is logged in

折月煮酒 提交于 2019-12-05 16:39:37
I'm new in asp.net mvc and i need to check if a user is logged in or not in my application so i place the following piece of code in my global.asax void Application_PreRequestHandlerExecute(object sender, EventArgs e) { HttpApplication application = (HttpApplication)sender; HttpContext context = application.Context; string filePath= context.Request.FilePath; string fileExtention = VirtualPathUtility.GetExtension(filePath); // to skip request for static content like (.css or .js) if (fileExtention == "") { if (filePath.ToLower() != "/account/login") { var user = (Utilisateur)context.Session[

How do I detect if a request is a callback in the Global.asax?

空扰寡人 提交于 2019-12-05 14:06:56
I need to find a way to detect if a request is a callback when the Application_BeginRequest method is called. Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)<br /> Dim _isCallBack As Boolean = False ' Code to set _isCallBack is True or False Here If Not _isCallBack Then '... Some Code End If End Sub I need to know what to replace "[Code to set _isCallBack is True or False Here]" with. This may help you: http://msdn.microsoft.com/en-us/magazine/cc163941.aspx Search for the word __CALLBACKID: To determine the callback mode, the ASP.NET runtime looks for a __CALLBACKID

How can you hook a SharePoint 2007 feature into the Application_Start of a site?

北城以北 提交于 2019-12-05 12:29:41
I was wondering if there is a good way to hook into the Application_Start of a SharePoint 2007 site when developing a feature? I know I can directly edit the Global.asax file in the site root, but is there a way to do this so that it gets deployed with the feature? Thanks! This is actually possible, but it doesn't involve the Global.asax file. Many of Microsoft's examples demonstrate wiring code in via the Global.asax, but this is not a best-practices approach when it comes to SharePoint. Ideally, your code should get packaged as a Feature and deployed via WSP (as you already know). The key

Can you run a “service” that runs a scheduled task from an ASP.Net project?

十年热恋 提交于 2019-12-05 08:40:19
I built a Windows Service for a client of ours that collects all the changed/new rows from the database, turns them into a CSV and FTP uploads them somewhere every night. Now as it turns out they don't have access to install or run a Windows Service (it's a web path only hosted solution). I thought it would be easy enough to modify the Windows Service code to run inside the ASP.Net process and instantiated from the Global.asax (I've done this in the past, hosting a WCF service from within a MVC project). We're on ASP.Net 4.0, using web forms, and this task runs Quartz and OpenPG every night at

ASP.NET MVC routing conflict - null value for input variable

不羁的心 提交于 2019-12-05 07:57:15
I'm at a loss as to why my routes are conflicting. I have these in my Global.asax file: routes.MapRoute( "CustomerView", "{controller}/{action}/{username}", new { controller = "Home", action = "Index", username = "" } ); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "0" } ); So far everything has worked fine except when I created a controller action like so: public ActionResult MyAction(int id) { //Do stuff here return View(); } When I try viewing it through http://mydomain/MyController/MyAction/5 I get: Server Error in '/'

classic asp/asp.net website - global.asa not working

有些话、适合烂在心里 提交于 2019-12-05 07:12:11
I've recently been given a website written in classic asp to configure and set up - although it also appears to have pages written in asp.net. The problem I'm having at the moment is that it doesn;t appear to be picking up settings from the global.asa file such as Application("ConnectionString").... As when I try to write them out from somewhere in the code - nothing appears. Any idea how to congure this website to use global.asa...or why it's not already using it? There is web.config file and global.asax...shouldn't this just be for .net? The code will not compile in visual studio. I've seen

Global.asax Error handling: Quirks of server.transfer

放肆的年华 提交于 2019-12-05 07:07:49
问题 In my global.asax, I am checking for a 404, and transferring to the 404 error page as per the below: If HTTPExceptionInstance.GetHttpCode = 404 Then Server.ClearError() Response.TrySkipIisCustomErrors = True Response.Status = "404 Not Found" Server.Transfer("~/Invalid-Page.aspx") End If The problem is, my Invalid-page.aspx uses some session code (Session("somevariable")), which throws an exception "Session state can only be used when enableSessionState is set to true, either in a

Check for a static file during Application_BeginRequest?

放肆的年华 提交于 2019-12-05 06:12:19
I have a Global.asx file that needs to do custom authentication, auditing and profiling stuff. This is needed because it supports a SAML based SSO system and needs to override the normal .Net authentication (which doesn't support either SAML or mixed authentication) I don't want to fire it for static files, such as .js , .css , .png , etc In Cassini/WebDev and IIS7 it does. What I want to have is some simple check, like a this.Request.IsStaticFile (which doesn't exist, unfortunately) to identify the static files. I realise that this would be fairly simple to write, but it feels like something