简体   繁体   English

asp.net mvc服务器显示目录但不显示

[英]asp.net mvc server shows directory but not view

I am just learning asp net mvc. 我只是在学习asp net mvc。 I have trying to make my web application works) The problem is server (debug from visual studio) shows directories not my view. 我试图使我的Web应用程序正常运行)问题是服务器(来自Visual Studio的调试)显示目录而不是我的视图。 Something like that: 像这样:

04.12.2014    10:54        <dir> App_Data
04.12.2014    14:50        <dir> App_Start
04.12.2014    14:50        <dir> bin
04.12.2014    10:54        <dir> Content
04.12.2014    14:47        <dir> Controllers
04.12.2014    13:55          859 FondControllerFactory.cs
04.12.2014    10:54           99 Global.asax
04.12.2014    14:47         1280 Global.asax.cs
04.12.2014    14:47        <dir> Models
04.12.2014    10:54        <dir> obj
04.12.2014    10:59         2713 packages.config
04.12.2014    14:38        <dir> PluginSys
04.12.2014    10:54        <dir> Properties
04.12.2014    10:59        <dir> Scripts
04.12.2014    13:55        <dir> Views
04.12.2014    14:48         6804 Web.config
04.12.2014    10:54         1285 Web.Debug.config
04.12.2014    10:54         1346 Web.Release.config
04.12.2014    14:32        17677 WebFond.csproj
04.12.2014    14:32         1671 WebFond.csproj.user

So i dont understand where the problem? 所以我不明白问题出在哪里? My RouteConfig.cs is: 我的RouteConfig.cs是:

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            name: "Default",
            url: "{controller}/{action}/{guid}",
            defaults: new { controller = "Desktop", action = "Index", id = UrlParameter.Optional }
        );
    }
}

The default controller I want to use is DesktopController. 我要使用的默认控制器是DesktopController。 There is nothing special, DesktopController inherit Controller and implements my own IDesktop interface. 没什么特别的,DesktopController继承了Controller并实现了我自己的IDesktop接口。

So I cant understad why it broked. 因此,我无法理解它为什么破裂。 Ps 聚苯乙烯

If it needed i can post my Web.config 如果需要,我可以发布我的Web.config

So the first thing that is going to have to change is id = UrlParameter.Optional needs to be guid = UrlParameter.Optional . 因此,首先需要更改的是id = UrlParameter.Optional需要更改为guid = UrlParameter.Optional Take note that {controller} and controller = ... match. 请注意{controller}controller = ...匹配。

Next, you need to make sure there is an Index.cshtml in the Views\\Desktop folder so that the view can be rendered when calling return View(); 接下来,您需要确保Views\\Desktop文件夹中有一个Index.cshtml ,以便在调用return View();时可以呈现return View(); from the controller. 从控制器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM