Please find below my ActionResult Index:
public ActionResult Index(string SectionText)
{
var products = from p in db.Products
where p.CategoryID == SectionText
//orderby gs.SortBy
select p;
return View(products.ToList());
}
This is throwing the error below: –
Server Error in ‘/’ Application.
The resource cannot be found.
Description: 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:
/Sections/daughterboards-894/
Any Ideas would be much appreciated. this is using the built in vs web server.
Thanks
Well you are requesting
/Sections/daughterboards-894and there’s nothing that would relate this url to theIndexaction. If you are using the default routes your request should look like this:/sections/index/daughterboards-894Of course this assumes that you have a route capable of handling this URL:
If you want to have an url like
/Sections/daughterboards-894/you will need to set a special route for it:Remark: As a side note I would recommend you abstracting your data access into a repository instead of directly accessing it in your controllers. This will make your code much easier to unit test.