简体   繁体   中英

asp.net mvc server shows directory but not view

I am just learning 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. 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:

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. There is nothing special, DesktopController inherit Controller and implements my own IDesktop interface.

So I cant understad why it broked. Ps

If it needed i can post my Web.config

So the first thing that is going to have to change is id = UrlParameter.Optional needs to be guid = UrlParameter.Optional . Take note that {controller} and controller = ... match.

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(); from the controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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