在托管服务器上发布时,默认页面代码隐藏不起作用

本文关键字:默认 代码 不起作用 隐藏 布时 服务器 | 更新日期: 2023-09-27 18:19:59

我决定不将第一个访问者从默认重定向到我的"未登录"页面,只在"未登录"页面中启用默认。当我这样做的时候,除了页面加载之外,没有任何代码在codeehind中工作。我有一个非常好用的菜单,但主页中的任何链接按钮或登录代码都不起作用。也许这与主机提供商重写url有关?我的页面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();
    }

这是defalt.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" />

在托管服务器上发布时,默认页面代码隐藏不起作用

结果是因为我启用了CrossAppRedirects="true"