Lets say i have a url- myurl.com/something
I want it to hit at home controller and want to retrieve the last part "something". Something will be dynamic.
Is there any way to do it?
Lets say i have a url- myurl.com/something
I want it to hit at home controller and want to retrieve the last part "something". Something will be dynamic.
Is there any way to do it?
Are you trying to do that for many URLS? If it's not something for lots of URLs you could get away redirecting from the BeginRequest or EndRequest functions in the Global.asax.
I once did this in VB.NET (probably easy to get it done in C# as well)
Dim context = New HttpContextWrapper(HttpContext.Current)
Dim rd As RouteData = RouteTable.Routes.GetRouteData(context)
If rd IsNot Nothing Then
Try
If rd.GetRequiredString("controller") IsNot Nothing Then
Dim _controller As String = rd.GetRequiredString("controller").ToLower
Dim _action As String = rd.GetRequiredString("action").ToLower
Dim cond1 As Boolean = _controller = "home" And _action = "index"
If cond1 Then
__DO SOMETHING__
End If
End If
Catch ex As Exception
End Try
End If