0

thought i was having an error with the folder structure but i think my deployed mvc app isn't picking up the web pages because of the extension.

When I type in the root directory it loads up the index page without the .cshtml.

When i try to use one of the links from that page the url loads without the .cshtml and says

404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

if i append it to have .cshtml at the end i get

Server Error in '/' Application.

This type of page is not served.

Description: The type of page you have requested is not served because it has been explicitly forbidden.  The extension '.cshtml' may be incorrect.   Please review the URL below and make sure that it is spelled correctly. 

Requested URL: /Employee/_ViewEmpDetails.cshtml

Is there some setting i have missed? never deployed one of these before!

EDIT

have tried running

C:\Windows\Microsoft.NET\Framework\v4.0.30319>aspnet_regiis -i

but no joy.

EDIT2

my route config in case it has something to do with this:

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 = "Treeview", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
JQuery
  • 889
  • 3
  • 13
  • 35

1 Answers1

1

The default search paths when MVC looks for a view are these:

~/Areas/AreaName/Views/ControllerName/ViewName.aspx
~/Areas/AreaName/Views/ControllerName/ViewName.ascx
~/Areas/AreaName/Views/Shared/ViewName.aspx
~/Areas/AreaName/Views/Shared/ViewName.ascx

~/Views/ControllerName/ViewName.aspx
~/Views/ControllerName/ViewName.ascx
~/Views/Shared/ViewName.aspx
~/Views/Shared/ViewName.ascx

~/Areas/AreaName/Views/ControllerName/ViewName.cshtml
~/Areas/AreaName/Views/ControllerName/ViewName.vbhtml
~/Areas/AreaName/Views/Shared/ViewName.cshtml
~/Areas/AreaName/Views/Shared/ViewName.vbhtml
~/Views/ControllerName/ViewName.cshtml
~/Views/ControllerName/ViewName.vbhtml
~/Views/Shared/ViewName.cshtml
~/Views/Shared/ViewName.vbhtml

If these will not work for you, you can customize them by extending the WebFormViewEngine and registering it in Global.asax.

Community
  • 1
  • 1
Brad C
  • 2,868
  • 22
  • 33
  • Is it possible i have not set it to look for .cshtml files? as if i add that it gives a different error saying the file cannot be served, – JQuery Jul 14 '15 at 07:23
  • You edited your question to an entirely new one.....? Anyways, that error seems as if it is finding the cshtml views fine but there is a configuration error serving it, either in IIS or your web.config. If you [search for your new error](http://stackoverflow.com/questions/12934932/this-type-of-page-is-not-served-error-when-trying-to-browse-on-cshtml-files), there are a [ton of hits](http://stackoverflow.com/questions/8858986/mvc3-error-message-cshtml-the-type-of-page-you-have-requested-is-not-served-be). – Brad C Jul 14 '15 at 12:26