1

I have a 3rd party Asp.net (.NET 4.0) web application for which I'm responsible for developing additional content. I need to be able to use MVC and WebApi and so I need to be able to map routes.

Is there a way I can do this without having access to Application_Start (I don't have their source code)?

Sean
  • 868
  • 9
  • 22

2 Answers2

0

No But if you have IIS access you can use iis url rewrite rule. check for this module in IIS "URL Rewrite" in iis.net

meetkichu
  • 131
  • 1
  • 6
0

You can use the new

[assembly: PreApplicationStartMethod(typeof(XYZ.SomeClassType), "InitializeCASHttpModule")]

Attribute to do this.

  1. Create a new Class Library Project
  2. Use NuGet Console to add the MVC package that the third part site depends on, e.g. Install-Package MVC -Version 4.0.1.02157 (guessing here).
  3. Create a public static method in a class to register your routes.
  4. In the Properties folder of your class library, open the AssemblyInfo.cs file add the assembly attribute above, using the using the type of the class you just made and the name of the public static method.

Drop the dll in the third party websites Bin Directory and restart it's app pool.

Ryan Mann
  • 5,178
  • 32
  • 42
  • Does the assembly which contains the PreApplicationStartMethod attribute need to be referenced by the 3rd party web application? Simply putting the dll in the bin directory will enable Asp.net to be aware of it without a dll reference to it somewhere? – Sean Sep 17 '14 at 15:31
  • Ah.. Yeah, Make another class called EnableMyRoutes and derrive it from ConfigurationSection. Then add a new config section to the web.config, then add your section e.g. That will make the w3wp process load your dll, which will then run the code. – Ryan Mann Sep 17 '14 at 15:38
  • Better yet, use the assembly binding elements to set your dll as a dependent assembly on the dll of the third party web app. http://stackoverflow.com/questions/7040432/set-location-of-dlls-to-load-in-web-config – Ryan Mann Sep 17 '14 at 15:39