1

I have an Asp.Net Web Forms project, later on I've added the WebApi support to it, so now I can access both the .aspx pages + controller action api.

Now, The startup process takes up to 50 seconds, after profiling, I've noticed that one of the issues is System.Web.Http.Routing.AttributeRoutingMapper() takes about 10 seconds (most probably because it uses reflection to resolve controllers). enter image description here

The project loads many assemblies (hundreds), and we have some very big auto-generated classes which may slow down the reflection process.

What I am thinking is to to move all controllers to a separate assembly and force the router to look only their.

Is this possible, if yes can you give me some hints how ?

Notes: removing assemblies, reducing classes sizes is out of scope for me.

amd
  • 20,637
  • 6
  • 49
  • 67
  • Have you considered removing the automated route mapping using `MapAttributeRoutes` and do it manually in your code? – Imantas Dec 19 '18 at 14:06
  • you can have a look at this https://stackoverflow.com/questions/401376/asp-net-mvc-put-controllers-into-a-separate-project – GoldenAge Dec 19 '18 at 14:06
  • I understand that you have to deal with some legacy system and you want to add some modern stuff to it, so it would be easier to maintain it, am I right? – GoldenAge Dec 19 '18 at 14:09
  • @ImantasSankalas, can you give more hints about this ? – amd Dec 19 '18 at 14:49
  • @GoldenAge, yes this is the case – amd Dec 19 '18 at 14:50
  • I'm not sure if its a good idea mixing old Web-forms (and I guess huge)project with MVC stuff. If you want to add MVC stuff to it, its probably because you want to build some new extra features to the system or rewrite the existing stuff. If I were you I would try to go into microservices architecture. – GoldenAge Dec 19 '18 at 14:55
  • So for example lets say you have an old shop with clothes build in WebForms and you want to add a new Panel called e.g. "Golden Client". You can e.g. create a new .net core web api in a separate project, build extra UI in Angular/ReactJS or whatever you want, it can be even the standard MVC project based on Razor and you can communicate between old WebForms app and the new .net core app using HTTP. I know this is not the answer to your question. But its an option which you can consider – GoldenAge Dec 19 '18 at 15:00
  • @amd what I was trying to say is remove the call to `MapAttributeRoutes` and use routing table as described in [this link](https://learn.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api) – Imantas Dec 19 '18 at 15:01
  • @GoldenAge, thanks for the suggestion, but in my situation, this option is not possible. – amd Dec 19 '18 at 15:16

0 Answers0