How To Get Routing Details In Static Class

Hello Word, in this post I am going to show how we can get the Routing Information in the static class. During development sometime we need to create a static class but this class may be used from the entire project so sometimes system throws an error that cannot call non static method in the static class. So I am going to show you How we can get Routing Information in Static Class? we simply need this, get current http request and use RequestContext property to get request context – it has current routing data. For Example:


So from above mentioned code we can easily get the necessary Information about “ActionName”,” ControllerName”,” ID “etc from Routing Data, which saved in the current request

Leave a Reply