Last post May 28, 2014 02:42 AM by Ashim Chatterjee
May 26, 2014 02:37 AM|Jeevanathan|LINK
I have working with a project, where activation links will be sent to the user for new registration. When the user clicks the link it has to load the Activation page instead because of my web.config file setting it redirects to login.aspx page.
I do request to let me know a solution for such issue.
Thanks in advance!!!
May 27, 2014 01:54 AM|Kevin Shen - MSFT|LINK
Based on my understanding about your post,it seems that you have enabled
Form Authentication in your application.
Please check your web.config ,see if it has code like below:
<forms loginUrl="Logon.aspx" name=".ASPXFORMSAUTH">
If it does,please reomve it from your web.config.
May 28, 2014 01:39 AM|Jeevanathan|LINK
yes I used the code in web.config,
but if i remove it, my project is not at all running.
It throws the erro, "Server error in '/' Application"
May 28, 2014 01:42 AM|Ashim Chatterjee|LINK
You have to maintain a separate folder where you will have the activation page with access rights to anonymous users.On your web.config you can allow access to other users :
<allow users="?" />
Hopefully this will not prevent you to access the activation page and wont redirect you back to login page.Let me know if you have any further issues. :)
May 28, 2014 01:54 AM|Jeevanathan|LINK
I tried this too, no use :(
May 28, 2014 02:00 AM|Ashim Chatterjee|LINK
I think you can bypass the forms authentication protocols using httpsuppressformsauthenticationredirect property.Add below lins in your
protected void Application_EndRequest(Object sender, EventArgs e)
HttpApplication context = (HttpApplication)sender;
context.Response.SuppressFormsAuthenticationRedirect = true;
protected void Application_EndRequest(object sender, EventArgs e)
HttpApplication application = (HttpApplication)sender;
if (application.Response.StatusCode != 401 || !application.Request.IsAuthenticated) return;
var customErrors = (CustomErrorsSection)ConfigurationManager.GetSection("system.web/customErrors");
var accessDeniedPath = customErrors.Errors["401"] != null ? customErrors.Errors["401"].Redirect : customErrors.DefaultRedirect;
return; // Let other code handle it (probably IIS).
Now in web.config write below:
<customErrors mode="On" defaultRedirect="GlobalErrorPage.aspx">
<error statusCode="401" redirect="Activation.aspx" />
May 28, 2014 02:33 AM|Jeevanathan|LINK
I have found the problem will let u know my flow firstly.
Only admin can register an user, if he registered the respective user will receive the activation link to activate his account.
The problem what i found is, the activation link sent to the user is given below,
where this link contains the Admin folder which is restricted for Admins only,
i use "Request.Url.AbsoluteUri.Replace("Register.aspx", "Activation_Status.aspx?ActivationCode=" + activationCode)" this code to generate the link.
Since my Register.aspx page is in the Admin folder, so i changed it into some other folder, and now that generating url is being changed. Anyhow i got the correct url though when user clicks the link it throws the error "
May 28, 2014 02:40 AM|Jeevanathan|LINK
YAH!!! its working now
i have used if (((System.Web.Security.FormsIdentity)(HttpContext.Current.User.Identity)).Ticket.UserData == "Admin") this code in my site.master.cs code, i commented it and now tis working. thank u for ur suggestions!!!
May 28, 2014 02:42 AM|Ashim Chatterjee|LINK
Glad you made it. :)