very simple basic question
I have only route:
routes.MapRoute(
"Widget", // Route name
"Widget/Frame/{postUrl}", // URL with parameters
new { controller = "Widget", action = "Index", postUrl = UrlParameter.Optional } // Parameter defaults
);
And when i try to open following url:”http://localhost:50250/Widget/Frame/qwerty”
I have an error:
The view ‘qwerty’ or its master was not found or no view engine
supports the searched locations. The following locations were
searched:
Well…why?
Controller code:
public class WidgetController : Controller
{
//
// GET: /Widget/
public ActionResult Index(string postUrl, int? blogEngineType)
{
return View(postUrl);
}
}
I would hazard a guess and say it’s because it’s actually trying to use the action name of Index(), since that’s the default action that you’ve specified. You’re not passing an {action} parameter through the url, so where else will it get the action from?
Can you change your url pattern to
Widget/{action}/{postUrl}and see if it works then?Either that, or set the default value of
actiontoFrameinstead. Basically, it has no way of knowing that you’re looking for theFrameaction, so it fails.Edit: I see what you’re doing now – the action’s name is actually Index, right? In that case, I’m not sure, we need to see your controller code. I’ll leave the above answer in case it’s useful.
Edit 2: You’re passing the value “qwerty” as the view name – do you have a view named “qwerty” in the views folder?
If you intend for it to be the model, and for the view name to be “Index”, you should call
return View((object)postUrl);instead, so that it doesn’t get confused.