Just wondering if anyone can help me.
I have an MVC project and in my view I'm using url.action to link to my action. My action can handle 3 optional parameters Category, SubCategory and a Name. But the problem is SubCategory could be Null so I need Name to replace Subcategory in the URL.Action link. I have my code working but I'm wondering if there is a better way of writing this code.
My URL.Action:
if(subcategory == null)
{
<a href="@Url.Action("Action", "Controller", new { Parameter1 = Category, Parameter2 = subcategory, DataParameter3 = name})">Products</a>
}
else
<a href="@Url.Action("Action", "Controller", new { Parameter1 = Category, Parameter2 = name})">Products</a>
Does any one know a better way of doing this??