Bijayalaxmi Panda
Bijayalaxmi Panda

Reputation: 1

MVC 5 routeconfig error

routes.MapRoute( 
    name: "Default", 
    url: "{controller}/{action}/{id}", 
    defaults: new 
    { 
        controller = "ImageScan", 
        action = "ScanImage", 
        id = UrlParameter.Optional 
    }, 
    namespaces: new[] { "WebApplication3.Controllers" } );

I get the error:

HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Views/ImageScan/ScanImage.cshtml

Upvotes: 0

Views: 170

Answers (1)

Shyju
Shyju

Reputation: 218732

You do not request a view directly. You should request a controller action which may or may not return the corresponding view.

Try

yourAppBaseAddress/ImageScan/ScanImage

Assuming you do not have any other custom routing definied to override the default routing conventions, This will hit the ScanImage action method inside the ImageScanController. If this action method is returning this view, you should be able to see the result of this views' code executed.

public ActionResult ScanImage
{
   return View();
}

When the line return View gets executed, the MVC framework will look for a view called ScanImage.cshtml in ~/Views/ImageScan and ~/Views/Shared directories.

Upvotes: 2

Related Questions