for Index action i need to pass Guid but it should be null as i’m checking it for edit or delete action.
I have used like this but getting compile error : Guid Cannot be null must be compile time constant.
or runtime error :
The parameters dictionary contains a null entry for parameter ‘uid’ of non-nullable type ‘System.Guid’ for method ‘System.Web.Mvc.ActionResult Index(System.String, System.Guid)’ in ‘Mapping.Controllers.HomeController’. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
public ActionResult Index(string userAction, Guid uid = new Guid() )
{
----
----
}
Try using a nullable
Guidfor your parameter:Based on your comments, assuming
objModel.Idis aGuid, you can use:However, knowing more about your situation now, I would look to
themarcuz‘s answer for a better overall solution.