Simple ASP.NET MVC views without writing a controller

后端 未结 5 566
一整个雨季
一整个雨季 2021-01-04 10:50

We\'re building a site that will have very minimal code, it\'s mostly just going to be a bunch of static pages served up. I know over time that will change and we\'ll want

5条回答
  •  独厮守ぢ
    2021-01-04 11:47

    This link might be help,

    If you create cshtml in View\Public directory, It will appears on Web site with same name. I added also 404 page.

    [HandleError]
        public class PublicController : Controller
        {
            protected override void HandleUnknownAction(string actionName)
            {
                try
                {
                    this.View(actionName).ExecuteResult(this.ControllerContext);
                }
                catch
                {
                    this.View("404").ExecuteResult(this.ControllerContext);
                }
            }
        }
    

提交回复
热议问题