This is what I'm trying to run:
If ControllerContext.RouteData.Values.Count = 0 Then
ViewData("subdata") = ""
ViewData("subdata") = ControllerContext.RouteData.Values("id").ToString
When I browse to www.mysite.com/mycontroller/myaction/myid, everything works ok. But visiting www.mysite.com/mycontroller/myaction produces:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceE
View Complete Post