I have a controller class Movie. One of its action method is given as follows:
public string ActionMethod(string id)
{
if (id == null)
{
return "null";
}
if (id == string.Empty)
{
return "empty";
}
return "neither null nor empaty";
}
Is it possible to pass an empty string to an action method with a routed URL segment rather than a query string?
Note that http://localhost:21068/Movies/ActionMethod?id= can do that but it uses a query string. In addition, it is not allowed to modify the action method. 🙂
I’m not clear about what you’re trying to achieve, but you can probably do it by specifying routes appropriately in Global.asax.cs. As a contrived example, the following:
lets you use:
If you state what URLs you want to allow and how to map them, someone will no doubt suggest how you can set up your routes.