我想爲我的網站添加一個新的視圖,但我一直在'/'應用程序中獲取錯誤服務器錯誤。我的視圖鏈接到控制器,我的路由配置文件有正確的路徑。任何幫助將不勝感激。服務器錯誤'/'應用程序MVC 5
檔案控制器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Bitev2.Controllers
{
public class ProfileController : Controller
{
//
// GET: /Profile/
public ActionResult Index()
{
return View();
}
//
// GET: /Profile/Details/5
public ActionResult Details(int id)
{
return View();
}
//
// GET: /Profile/Create
public ActionResult Create()
{
return View();
}
//
// POST: /Profile/Create
[HttpPost]
public ActionResult Create(FormCollection collection)
{
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
//
// GET: /Profile/Edit/5
public ActionResult Edit(int id)
{
return View();
}
//
// POST: /Profile/Edit/5
[HttpPost]
public ActionResult Edit(int id, FormCollection collection)
{
try
{
// TODO: Add update logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
//
// GET: /Profile/Delete/5
public ActionResult Delete(int id)
{
return View();
}
//
// POST: /Profile/Delete/5
[HttpPost]
public ActionResult Delete(int id, FormCollection collection)
{
try
{
// TODO: Add delete logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
}
}
資料視圖
@{
ViewBag.Title = "Profile";
}
<h2>Profile</h2>
路由配置文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace Bitev2
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
對於哪個網址,您遇到此錯誤?你可以分享該網址嗎? – ramiramilu
你有家庭控制器嗎? –
我想,你必須在運行時輸入id或你正在使用哪種認證。檢查web.config文件。 –