Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm facing an issue which is causing infinite loop, causing OnpreRender method infinite loop every time, this is the below login page in sharepoint page
C#
public partial class Login : FormsSignInPage
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        bool testJS = IsJSEnabled;
        if (Request.QueryString[JSQRYPARAM] != null)
        {
            IsJSEnabled = Request.QueryString[JSQRYPARAM] == JSENABLED;
        }
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (IsJSEnabled)
        {
            string targeturl = GetAppendedUrl(JSQRYPARAM, JSDISABLED);
            HtmlGenericControl ctrl = new HtmlGenericControl("NOSCRIPT");
            ctrl.InnerHtml = string.Format("<meta http-equiv=REFRESH content=0;URL={0}>", targeturl);
            Page.Header.Controls.Add(ctrl);
        }
        else
        {
            if (!string.IsNullOrEmpty(NonJSTargetURL))
                Response.Redirect(NonJSTargetURL);
            HtmlGenericControl ctrl = new HtmlGenericControl("NOSCRIPT");
            ctrl.InnerHtml = string.Empty;
            Page.Header.Controls.Add(ctrl);
        }
    }

In aspx page i write like this, this implemntation usefull to find whether javascript enabled in browser or not
Posted
Updated 9-Jul-15 23:49pm
v2
Comments
Timberbird 10-Jul-15 7:34am    
This line
Response.Redirect(NonJSTargetURL);
seems rather suspicious. What is NonJSTargetURL? Could it be that you keep redirecting user to the same login page again and again? Even if JS is enabled on client side, it could be that by some weird logic browser still executes Refresh action included in noscript element.

So, I suggest that you check if you are redirecting visitor's browser on each request - by monitoring browser's network activity (using built-in tools or eg Fiddler proxy) or checking IIS logs, for example.

Also, why do you introduce testJS variable if you don't actually use it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900