在托管服务器上发布时,默认页面代码无效

时间:2012-01-11 21:40:07

标签: c# asp.net

我决定不将第一个访问者从默认设置重定向到我的“未登录”页面,只需在“未登录”页面中转为默认设置。当我这样做时,除了页面加载之外,代码中没有任何代码正在工作。我有一个完美的菜单,但主页中的任何链接按钮或登录代码都不起作用。也许它与重写托管服务提供商的网址有关?我的页面在url中没有default.aspx,只显示www.mywebsite.com

这是默认情况下的页面加载。

if (!IsPostBack)
        {
            AbuseReport abuse = new AbuseReport();
            abuse.Message = "page load clicked";
            abuse.ReportingPersonID = 1;
            abuse.AbuserPersonID = 1;
            abuse.CreateAbuseReport();

            SiteViews();

            bool stayOnSite = (Session["StayOnMainSite"] != null && !Parser.GetBoolean(Session["StayOnMainSite"]));

            string strUserAgent = Request.UserAgent.ToString().ToLower();

            if (strUserAgent != null)
            {
                if (Request.Browser.IsMobileDevice == true || strUserAgent.Contains("iphone") ||
                    strUserAgent.Contains("blackberry") || strUserAgent.Contains("mobile") ||
                    strUserAgent.Contains("windows ce") || strUserAgent.Contains("opera mini") ||
                    strUserAgent.Contains("palm") || strUserAgent.Contains("android") ||
                    strUserAgent.Contains("ipad") || strUserAgent.Contains("moto") ||
                    strUserAgent.Contains("htc") || strUserAgent.Contains("sony") ||
                    strUserAgent.Contains("panasonic") || strUserAgent.Contains("midp") ||
                    strUserAgent.Contains("cldc") || strUserAgent.Contains("avant") ||
                    strUserAgent.Contains("windows ce") || strUserAgent.Contains("nokia") ||
                    strUserAgent.Contains("pda") || strUserAgent.Contains("hand") ||
                    strUserAgent.Contains("mobi") || strUserAgent.Contains("240x320") ||
                    strUserAgent.Contains("voda"))
                {
                    if (!stayOnSite)
                    {
                        Response.Redirect("~/Mobile/Default.aspx");
                        return;
                    }
                }
            }

            if (Session[ApplicationClass.UserSessions.AppUser] != null)
            {
                ApplicationClass appClass = ((ApplicationClass)Session[ApplicationClass.UserSessions.AppUser]);

                if (appClass.User.IsPolitician)
                {
                    UrlParameterPasser urlPasser = new UrlParameterPasser("~/PoliticianView/PoliticianWall.aspx");
                    urlPasser["PoliticianID"] = Parser.GetString(appClass.User.Politician.PoliticianID);
                    urlPasser.PassParameters();
                }
                else
                {
                    Response.Redirect("~/User/UserMain.aspx");
                }
            }
        }

这是我的登录点击(注册是相同的,滥用仅用于记录目的)

protected void lbtnLogin_Click(object sender, EventArgs e)
    {
        AbuseReport abuse = new AbuseReport();
        abuse.Message = "Login clicked";
        abuse.ReportingPersonID = 1;
        abuse.AbuserPersonID = 1;
        abuse.CreateAbuseReport();

        Response.Redirect("~/Login/Login.aspx");

        AbuseReport abuse2 = new AbuseReport();
        abuse2.Message = "Login after click";
        abuse2.ReportingPersonID = 1;
        abuse2.AbuserPersonID = 1;
        abuse2.CreateAbuseReport();
    }

这里是defualt.aspx

<%@ Page Title="Politic Profiles Main" Language="C#" MasterPageFile="~/TwoColumn.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="PoliticProfiles._Default" %>

<table cellpadding="10px">
    <tr>
        <td>
            <asp:Image ID="Image1" ImageUrl="~/Images/flags.jpg" AlternateText="American Flags" 
                runat="server" />
        </td>
        <td valign="top">
            <h1>Welcome to Politic Profiles</h1>

            <h2>Political information tailored to you.</h2>

            <br />

            <h3>
                <asp:LinkButton ID="lbtnRegister" runat="server" Text="Register" 
                onclick="lbtnRegister_Click" />
                <asp:Label ID="Label1" Text=" or " runat="server" />
                <asp:LinkButton ID="lbtnLogin" runat="server" Text="Login" 
                onclick="lbtnLogin_Click"/>
                <asp:Label ID="Label2" runat="server" Text=" to get the most out of your experience." />
            </h3>

            <ul class="landing">
                <li>
                    <asp:Label ID="Label3" runat="server" Text="Ask your politicians questions." />
                    <br /><br />
                </li>
                <li>
                    <asp:Label ID="Label4" runat="server" Text="Keep up to date with what your politicians are doing." />
                    <br /><br />
                </li>
                <li>
                    <asp:Label ID="Label5" runat="server" Text="Allow your politicians to learn from you." />
                    <br /><br />
                </li>
                <li>
                    <asp:Label ID="Label6" runat="server" Text="Be involved in polls that help inform you politicians what track you want them on." />
                    <br /><br />
                </li>
            </ul>
        </td>
    </tr>
</table>

<uc:Polls id="ucPolls" runat="server" />

<br /><br /> 

<uc:Donate id="ucDonate" runat="server" />

1 个答案:

答案 0 :(得分:0)

原来是因为我有enableCrossAppRedirects =“true”