从一页移动到另一页时,出现错误,找不到资源

时间:2019-04-29 21:27:24

标签: c# asp.net

登录后,当我尝试从一页移动到另一页时,出现此错误

  

“ /”应用程序中的服务器错误。无法找到该资源。   说明:HTTP404。您要查找的资源(或其资源之一)   依赖项)可能已被删除,名称更改或   暂时不可用。请查看以下网址并进行   确保拼写正确。

我的所有页面都有一个用于存储用户ID的会话变量。我也使用母版页,并且所有页面链接都在母版页中。 请帮我? 谢谢

第二个问题: 当我按下logotbutton时,将我定向到与登录页面相同的页面,但是在按下logout按钮之后,上述问题解决了。 请帮我。 谢谢

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="master_templete_student.Master.cs" Inherits="FYP_PROJECT.master_templete" %>

<!DOCTYPE html>

<html>
<body>

    <form id="form1" runat="server">
        <div>
            <nav class="navbar navbar-custom navbar-fixed-top" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#sidebar-collapse"><span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span></button>
                <a class="navbar-brand" href="#"><span>PHD Students</span>Information System</a>

                <ul class="nav navbar-top-links navbar-right">
                <li class="dropdown">
                          <Button ID="_Logout_Button" class="btn btn-danger fa fa-power-off" runat="server"   CausesValidation="false" onClick="Logout_button_Click" />
                          </li>
                    </ul>

                <ul class="nav navbar-top-links navbar-right">


                        <li class="dropdown">
                        <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#">
                        <em class="fa fa-bell"></em><span class="label label-info">5</span>
                    </a>

                    </li>
                </ul>
            </div>
        </div><!-- /.container-fluid -->
    </nav>
    <div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
        <div class="profile-sidebar">
            <div class="profile-userpic">
                <img src="http://placehold.it/50/30a5ff/fff" class="img-responsive" alt="">
            </div>
            <div class="profile-usertitle">
                <div class="profile-usertitle-name"><asp:Label ID="Label_Name" runat="server" Text="Label"></asp:Label></div>
                <div class="profile-usertitle-status"><span class="indicator label-success"></span>Online</div>
            </div>
            <div class="clear"></div>
        </div>
        <div class="divider"></div>

        <ul class="nav menu">
            <li><a href="Student_Profile.aspx">Profile</a></li>
            <li><a href="student_registration_form.aspx">Student Registration</a></li>
            <li><a href="approvel_for_research_abroad.aspx">Approval For Research Abroad</a></li>
            <li><a href="arrival_report_form.aspx">Arrival Report Form</a></li>
            <li><a href="departure_perfoma_form.aspx">Departure Perfoma</a></li>
            <li><a href="synopsis_form.aspx">Synopsis Form</a></li>

        </ul>
    </div><!--/.sidebar-->

    <div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
        <!--/.row-->



        <asp:Contentplaceholder ID="main"  runat="server"></asp:Contentplaceholder>


        </div><!--/.row-->
    </div>  <!--/.main-->




    </form>
</body>
</html>


 public partial class master_templete : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["LoginUserName"] == null)
            {
                Response.Redirect("~/Login_Form.aspx");

            }
            else
            {
                string str;
                str = Session["LoginUserName"].ToString();
                Label_Name.Text = str;
            }
        }

        protected void Logout_button_Click(object sender, EventArgs e)
        {

                Session.Remove("LoginUserName");
                Response.Redirect("~/Login_Form.aspx");
        }
    }

1 个答案:

答案 0 :(得分:0)

对于第一部分:您确定要响应具有绝对路径的资源,例如<a href="/abosulte-path-to-resource">而不是没有第一个<a href="relative-path-to-resource">的{​​{1}}吗?

第二部分:您是否修改了Web.config?