Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在MVC5现有项目中提供登录页面的链接?_C#_Html_Asp.net Mvc 5 - Fatal编程技术网

C# 如何在MVC5现有项目中提供登录页面的链接?

C# 如何在MVC5现有项目中提供登录页面的链接?,c#,html,asp.net-mvc-5,C#,Html,Asp.net Mvc 5,我在asp.net-MVC-5中有一个带有C#的现有示例项目。示例项目运行良好。但问题是,每当我运行项目时,项目都会指向我的光标所在的页面。例如,如果我在主索引页中编辑,则表示在运行项目时仅从主/索引页开始。但我只想从登录页面开始。如何给出正确的链接 我的编码如下: 我的视图开始为 @{ Layout = "~/Views/Shared/_Layout.cshtml"; } 我的布局为 <!DOCTYPE html> <html> <head>

我在asp.net-MVC-5中有一个带有C#的现有示例项目。示例项目运行良好。但问题是,每当我运行项目时,项目都会指向我的光标所在的页面。例如,如果我在主索引页中编辑,则表示在运行项目时仅从主/索引页开始。但我只想从登录页面开始。如何给出正确的链接

我的编码如下:

我的视图开始为

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
我的布局为

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Title</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")

</head>
<body>
    <div class="container body-content">
        @RenderBody()      
    </div>

    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)
</body>
</html>

标题
@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/modernizer”)
@RenderBody()
@Scripts.Render(“~/bundles/jquery”)
@Scripts.Render(“~/bundles/bootstrap”)
@RenderSection(“脚本”,必需:false)
我的登录页面位于路径中 ~Views/Account/Login.cshtml。 我的登录设计如下:

@using M.Models
@model LoginViewModel
@{
    ViewBag.Title = "Log in";
     Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Log in</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="~/Content/adminlte/components/bootstrap/dist/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="~/Content/adminlte/components/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="~/Content/adminlte/components/Ionicons/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="~/Content/adminlte/dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="~/Content/adminlte/plugins/iCheck/square/blue.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="~/Content/adminlte/dist/css/skins/_all-skins.min.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <!-- Google Font -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<body class="hold-transition login-page">
    <div class="login-box">
        <div class="login-logo">
            <img src="@Url.Content("~/Images/Logo.jpg")" alt="HRMS" width="360" /><br />
        </div>
        <!-- /.login-logo -->
        <div class="login-box-body">
            <p class="login-box-msg">Sign in to start your session</p>
            <form action="" method="post">
                <div class="form-group has-feedback">
                    <div class="input-icon">
                        @*<i class="fa fa-user"></i>*@
                        @Html.TextBoxFor(model => model.UserName, new { @class = "form-control placeholder-no-fix", @placeholder = "Username", @maxlength = "50" })
                        @Html.ValidationMessageFor(model => model.UserName)
                        <span class="glyphicon glyphicon-user form-control-feedback"></span>
                    </div>
                </div>
                <div class="form-group has-feedback">
                    <div class="input-icon">
                        @*<i class="fa fa-user"></i>*@
                        @Html.PasswordFor(model => model.Password, new { @class = "form-control placeholder-no-fix", @placeholder = "Password", @maxlength = "50" })
                        @Html.ValidationMessageFor(model => model.Password)
                        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                    </div>
                </div>
                @*<div class="form-group has-feedback">
                    <input type="text" class="form-control" placeholder="User Name">
                    <span class="glyphicon glyphicon-user form-control-feedback"></span>
                </div>
                <div class="form-group has-feedback">
                    <input type="password" class="form-control" placeholder="Password">
                    <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                </div>*@
                <div class="row">
                    <div class="col-xs-8">

                    </div>
                    <!-- /.col -->
                    <div class="col-xs-4">
                        <button type="submit" class="btn btn-primary btn-block btn-flat">Sign In</button>
                    </div>
                    <!-- /.col -->
                </div>               
            </form>
        </div>
        <!-- /.login-box-body -->
    </div>
    <!-- /.login-box -->
    <!-- jQuery 3 -->
    <script src="~/Content/adminlte/components/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap 3.3.7 -->
    <script src="~/Content/adminlte/components/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- iCheck -->
    <script src="~/Content/adminlte/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(function () {
            $('input').iCheck({
                checkboxClass: 'icheckbox_square-blue',
                radioClass: 'iradio_square-blue',
                increaseArea: '20%' /* optional */
            });
        });</script>
</body>
</html>
@使用M.模型
@模型LoginView模型
@{
ViewBag.Title=“登录”;
布局=空;
}
登录

登录以启动会话

@**@ @Html.TextBoxFor(model=>model.UserName,新的{@class=“表单控制占位符无修复”,@placeholder=“UserName”,@maxlength=“50”}) @Html.ValidationMessageFor(model=>model.UserName) @**@ @Html.PasswordFor(model=>model.Password,新的{@class=“表单控制占位符无修复”,@placeholder=“Password”,@maxlength=“50”}) @Html.ValidationMessageFor(model=>model.Password) @* *@ 登录 $(函数(){ $('input').iCheck({ checkboxClass:'icheckbox_square-blue', 无线电课堂:“伊拉迪奥广场蓝”, 递增面积:“20%”/*可选*/ }); });

提前感谢。

这是Visual Studio项目中的一个设置。转到项目属性并查看Web部分。将“开始操作”从当前页面更改为“开始URL”,并填写所需的URL,该URL很可能是您的项目URL。您可以从那里复制它。

勾选“正确答案”表示需要等待3分钟才能选择正确答案。三分钟后,我会勾选答案,先生。非常感谢。