web.config - catch Response.Redirect

I'm working an a SSO project.  On all of the sites, the forms login url is the login website. (login.mydomain.com), I'm redirected to the login page fine, but the ReturnUrl is just the page name, so if I'm on www.mydomain.com/Test.aspx, the ReturnUrl = /Test.aspx, not http://www.mydomain.com/Test.aspx.  I though an easy fix would be to catch this redirect in the global.asax and modify the url that I'm redirecting to for login, but I can't seem to find how to do it.

 I'm also up for a better solution if someone has a tried and proven one.



12/10/2008 6:02:42 AM
asp.net.config-deploy 12495 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 4
Get it on Google Play
Get it on Apple App Store

 I think that you can handle the LoggedIn event and test the Request.UrlReferrer to see where the login request came from?

12/10/2008 11:54:50 AM

Just an idea: couldn't you handle this in your login site by reading the referring URL (Request.UrlReferrer) and then (after login) redirect back to that URL?

Please mark this post as Answer if it was helpful.

-- Martin
12/10/2008 11:57:09 AM

I tried that initially, requesting the UrlReferrer And PathAndQuery, but I didn't always get the result that I wanted.

 I ended up solving this issue by using the PostAuthenticateRequest event in the global.asax, I guess I could also use an httpmodule for it.  Hope it helps someone. 

    Application_PostAuthenticateRequest(object sender, EventArgs e)
        // Check if user has access to requested resource
        HttpContext ctx = HttpContext.Current;
        if (!UrlAuthorizationModule.CheckUrlAccessForPrincipal(ctx.Request.AppRelativeCurrentExecutionFilePath, ctx.User, ctx.Request.RequestType))
            // If not, send to SSO login url
            ctx.Response.Redirect(String.Format("{0}?ReturnUrl={1}", FormsAuthentication.LoginUrl, ctx.Request.Url.AbsoluteUri));
12/10/2008 3:59:06 PM

Similar Artilces:

Web Deployment Project - Config Properties
I'm using a Web Deployment Project to compile my web site. In the Property Pages - Configuration Properties - Deployment section, there is an option to 'Enable Web.config file section replacement'. I have this working to replace certain sections of my web.config for each build config (release/staging/dev). I think this makes sense so other developers do not have to remember to change the web.config file. HOWEVER, this only seems to work when replacing parts of web.config; such as appSettings, connectionString, etc. This would require me to have separate config files for each section and bui...

running 2 web.configs in the same website 1 in /web.config and one in /swf/web.config
Im having issues doing this. and when i remove the authentication from the swf/web.config it still doesnt seem to be applying to the child website at all. Whats the proper way to set a child website? Thanks!!  The lower most web.config overrides all previous settings. So if you remove the section from the /swf/web.config whatever settings you have in the web.config in the next higher level will have an effect on the content of the child folder.So instead of removing a section, try giving appropriate settings in the /swf/web.config....

app.config and web.config deployments and installers
I use web deployment projects for changing web.config values based on the configuration build types I have setup (dev/test/stage/prod) and it works excellent for building installers in multiple environments.  Now, I am trying to do the same the Windows Applications.  How can I automate the changing of app.config values based on the build configuration (dev/test/stage/prod)?  Any help would be much appreciated. Thanks,Chris...

Need to put this in a web.config file. Transfer a collection from app.config to web.config.
<!--<setting name="Groups" serializeAs="Xml"> <value> <ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <string>GL CA Corporate Data</string> <string>GL CONT Contractors</string> <string>GL IT SolutionDelivery</string> </ArrayOfString> </value> </setting>-->   I need to put this in the below web.config.<?xml version="1.0"?><!-- Note: As an alternative to hand editing this fi...

After migration from .Net 1.1 to .Net 3.5 do I have to incorporate new web.config settings in old *.config file
Hi,I have successfully migrated web application from .Net 1.1 to .Net 3.5. Could you let me know whether I have to incorporate setting in new web.config (this new web.config file was generated automatically due to migration) into old *.config file?FYI: Old *.config file contains all application level settings required. So I will continue to use old.config file by removing new web.config file. Settings which are in new web.config file are:<configSections><sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup,...

[PATCH lib/Net/Config.pm, MANIFEST, t/lib/Mock/Socket.pm, lib/Net/Config.t] Add Tests for Net::Config
Here's a test suite for Net::Config. In the process of writing this, I've fixed an apparent bug that prevented single values from becoming array references when necessary. I think it's right, but perhaps Graham should weigh in on this. In the process, with some advice from perl-qa, I've added a mock object so the test could control the output of Socket::inet_ntoa() and Socket::inet_aton(). t/lib/Mock/ seemed like as good a place as any. I'm happy to rework this patch if it personally offends anyone whose opinion matters. :) -- c --- lib/Net/~Config.pm S...

Merging my web.config.mylibrary with the web.config
I see multiples web.config files in the framework 2.0 folder.  There is a way to had a web.config.mylibrary file that contains part of the configuration section.For example, I want that the profile section to be in the web.config.mylibrary file and when the web site will be load, the two web.config will be merge.  Is it possible to such thing ? Hi Biz, It is possible to-do this using the configSource property on configuration section elements.  You could then store different configuration sections in different configuration files in a distributed way.Here is a MSD...

Develop in .NET 3.5...Deploy on .NET 3.0...Assembly strong name issue in web.config
Hi. I develop locally using web developer express 2008. I have .NET 3.5 installed on the development machine.I am trying to deploy to a Windows Server 2003 machine running.NET 3.0.Not surprisingly, I get an error about the strong assembly names referenced all over my web.config when I try to access the site on the production server.I don't think any of my code truly relies on .NET 3.5--it should all be compatible with the 3.0 framework.Here's my error message:Parser Error Message: Could not load file or assembly 'System.Core, Version=, Culture=neutral, PublicKeyToken=b77...

Read info from web.config, machine.config, app.config....
I know how to read info from the web.config, see code:  Protected path As String = "/Framework" Protected config As Configuration = WebConfigurationManager.OpenWebConfiguration(path) How can I read also the data from machine.config and other config files, like the app.configs?Johan TheunissenMCPD, MCSE, MCTS BizTalk 2006==============================Please mark the most helpful reply/replies as "Answer". ...

.NET 2.0 encryption web.config/app.config options?
Situation: 13 servers containing both ASP .Net web sites and .NET apps. Servers are broken up in Developemnt, Test, and Production types.Issue: Need to encrypt all app.config and web.config files.Currently we are using .NET 1.1, so I had developed (test working, not yet deployed) a shared (GAC) utility that would be responsible for providing an interface to allow the encryption (DPAPI + Second Entropy) of information for the developer to manually place in each web.conf/app.config file during development. The backend of this utility was referenced by the *.config files in decrypting values on...

Forms Authentication
Hi I am creating a new Website Application that redirects the logged in user to a webpage based upon the role to which he belongs programatically in 'Authentication' event. I have designed the app. so that a User can belong to a single role at one time and I am using membership provider.  I have a web page that is stored in the rootfolder which is accessible by all users(including unauthenticated users). This webpage contains different menuitems and one of them is 'login'.  So If user A belongs to Role 'abc', he is redirected to a webpage in folder abc. S...

Should local Web.config overwrite Production Web.config
I have a hosting service that supporst ASP.net 2.0.  I have an SQL Server 2005 Express account with them.  I have just started using them and have written my first web app. I have read quite a few things but it is not clear to me whether or not when I copy my web site (using VWD) if I should copy the web.conf file or not.  My local app runs fine but after copying everything to my production web site, I am not able to access the production web site in my browser.  I suppose it may have something to do with the question I've asked concerning Web.config. Is there a partic...

App.config to Web.config
I have been running a console app, to process a paypal payment.  The code gets a value from the app.config file. <add key="PAYFLOW_HOST" value="payflowpro.paypal.com" /> However I have now incorporate the code into a web application and put the key into my web.config file, will the code now know to look for this key in this place? If your code is getting the value from your config file using ConfigurationManager.AppSettings["PAYFLOW_HOST"] then it should use the correct config file automatically.  Console apps, windows services and wind...

gmail config on web.config
Hi, I'm using the default security login control (login, forgot password...)I've trouble as gmail.com user to send e-mail for new password, regarding the STARTTLS command.I already wrote this in my web.config :  <system.net>  <mailSettings>      <!--   <smtp from="yahooname@yahoo.com.sg">    <network host="smtp.mail.yahoo.com.sg" password="xxxxxxxxxx" userName="yahooname"/>      </smtp>    &n...

Machine.config and Web.config
 I want to know list of settings in machine.config which cannot be overridden in web.config.. Thanks a lot in advance  I don't think that this information is specifically listed anywhere, but you can look in machine.config and look for: allowExeDefinition="MachineOnly"If you're running IIS 7 you need to also look at applicationhost.config and overrideModeDefault="Deny"...+++ Rick ---   Rick StrahlWest Wind TechnologiesMaking waves on the Web www.west-wind.com/weblog Thanks for reply can u tell me how can i look my IIS version...

Web resources about - web.config - catch Response.Redirect - asp.net.config-deploy

Wikipedia:Abuse response - Wikipedia, the free encyclopedia
For a list of current Abuse Response volunteers, or for information on how you can help with the Abuse Response project, please see the volunteers ...

George Pell’s Melbourne Response child sexual abuse program
THE victims of child sexual abuse within the Catholic Church just want to be heard.

'God isn't fixing this': US politicians condemned for response to latest mass shooting
In the aftermath of a serious tragedy, it's good advice not to reach for cliche. Particularly when those words aren't followed by action.

Santa lookalike has perfect response to little boy in restaurant
Customers "teary-eyed" over elderly man's reaction to young boy in doughnut shop

The Murders At Planned Parenthood And The Unbelievable GOP Response
Yesterday on Morning Joe , Joseph McQuaid, the publisher of the New Hampshire Union Leader, was asked why his newspaper was endorsing Chris Christie ...

Play Darth Vader with Siri and get some hilarious responses
The whole tech world is losing its mind with Star Wars mania, and Apple’s no exception. Hidden within Siri is a neat reference to George Lucas’ ...

Democratic Senator: Prayers Are ‘Wholly Insufficient’ Responses To Shootings
Democratic Senator: Prayers Are ‘Wholly Insufficient’ Responses To Shootings

Disaster-Response Robots Demonstrate Their Skills
This year's International Robot Exhibition in Tokyo is focused on robotic equipment for disaster relief.

Adriana Lima Shuts Down Justin Bieber Hookup Rumors With Epic Response
Adriana Lima Shuts Down Justin Bieber Hookup Rumors With Epic Response

The Latest: White House candidates clash over US terrorism response
Here's the latest news on the U.S. presidential candidates' remarks on how to respond and prevent attacks like the one that occurred last week ...

Resources last updated: 12/8/2015 3:34:24 AM