Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/282.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.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# 学习ASP.NETMVC并在';中构建用户管理器服务器错误/';应用_C#_Asp.net_Asp.net Mvc - Fatal编程技术网

C# 学习ASP.NETMVC并在';中构建用户管理器服务器错误/';应用

C# 学习ASP.NETMVC并在';中构建用户管理器服务器错误/';应用,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,对于我的一门课,我刚刚开始学习如何在ASP.NETMVC5中开发web应用程序。我们需要做的一件事是重新设计一个简单用户帐户管理器的视图,代码已经提供给我们使用和修改 问题是,当我在VisualStudio中实际运行代码时,我得到404错误,即“/”应用程序中的服务器错误 我相当肯定,当代码在课堂上展示时,它是有效的,但我不能让它在这里发挥作用 以下是示例代码,供感兴趣的人使用: UserManagerController.cs using System; using System.Collec

对于我的一门课,我刚刚开始学习如何在ASP.NETMVC5中开发web应用程序。我们需要做的一件事是重新设计一个简单用户帐户管理器的视图,代码已经提供给我们使用和修改

问题是,当我在VisualStudio中实际运行代码时,我得到404错误,即“/”应用程序中的服务器错误

我相当肯定,当代码在课堂上展示时,它是有效的,但我不能让它在这里发挥作用

以下是示例代码,供感兴趣的人使用:

UserManagerController.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CS610W6.Controllers
{
    public class UserManagerController : Controller
    {
        //
        // GET: /UserManager/
        public ActionResult Index()
        {
            //Use the application's DB context to access the Identity framework's users
            var UserList = new CS610W6.Models.ApplicationDbContext().Users.ToList();

            //Pass the UserList to the view
            return View(UserList);
        }
    }
 }
index.cshtml

@model List<CS610W6.Models.ApplicationUser>
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
@foreach (var item in Model)
{
    @item.UserName<br />
    @item.PasswordHash<br />
    @item.Id<br />
    @Html.ActionLink("Edit", "Edit", new { id = item.Id })
}
@型号列表
@{
ViewBag.Title=“Index”;
}
指数
@foreach(模型中的var项目)
{
@item.UserName
@item.PasswordHash
@item.Id
@ActionLink(“编辑”,“编辑”,新的{id=item.id}) }
编辑:这是错误的全文,如浏览器中所示

“/”应用程序中出现服务器错误

找不到资源

描述:HTTP404。您正在寻找的资源(或其 依赖项)可能已被删除、名称已更改或 暂时不可用。请查看下面的URL并进行修改 确保它拼写正确

请求的URL:/Views/index.cshtml

版本信息:Microsoft.NET Framework版本:4.0.30319; ASP.NET版本:4.0.30319.34274


由于您是MVC新手,我假设您在第一次尝试运行应用程序时会出现此错误

正如我们在错误中看到的,请求的URL是
/Views/index.cshtml

这个错误仅仅意味着,应用程序找不到任何路由。 您可以使用URL
yourdomain/UserManager/Index

或者您可以设置默认操作以在
RouteConfig

 routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "UserManager", action = "Index", id = UrlParameter.Optional }
            );
这里也是一个很好的文档


希望这有帮助

加上你的全部错误。你什么时候得到错误?