question

Pavan-5606 avatar image
0 Votes"
Pavan-5606 asked XingyuZhao-MSFT answered

Intercept the http Requests before clr execution without changing the source code

Hi all,

  Intercept the Http Requests before CLR Execution in c# without changing/touch the source code
   In java this feature is implemented like java agent using premain() method to implemeted java agent and we will inject or modify the code at runtime without changing the source code
   But .Net it is possible or not? Can u help me on this implementation and guide me how to solve this one????
dotnet-csharpdotnet-runtimedotnet-cli
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I would suggest that you explain the root problem that you are trying to solve.

If you need to manipulate the incoming request you can use IIS's URL rewrite capability.

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/iis-url-rewriting-and-aspnet-routing

0 Votes 0 ·

Hi @MotoX80

Now we have two applications one server side and and another client side

We need to inject/modify code at runtime before CLR execution without changing the source code

Example:
Login page if we click the login function than it moves to CLR but our concept is before execution we need to modify/inject the code without source code
I think you understood this problem

0 Votes 0 ·

Well, maybe another forum user has an answer for you.

I'm trying to envision what you are trying to accomplish and I'm coming up empty. What are you going to inject? If you want to replace an event handler you would need to know the function name and what parameters are being passed to it. If you wanted to modify variables, you would need to know their names or somehow extract their address within the process memory. It seems to me that you would need to know a lot about the internal structure of the application and without the source code I don't see how you are going to do that.

Have you looked at disassemblers?

https://www.bing.com/search?q=dot+net+disassembler

0 Votes 0 ·

1 Answer

XingyuZhao-MSFT avatar image
0 Votes"
XingyuZhao-MSFT answered

Hi @Pavan-5606 ,

You can consider AOP solution in .NET.

Here's a reference you can refer to.
What is the best implementation for AOP in .Net?

Hope it could be helpful.
Best Regards,
Xingyu Zhao


If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.