Reputation: 33998
I have this code:
https://github.com/nbarbettini/SimpleTokenProvider/tree/master/test/SimpleTokenProvider.Test
Which was done with .net CORE, its a WEB API with .net CORE.
I need to implement a WEB API with the same security, but with .net framework not dot net core.
Where do I need to put the code from Startup.cs, StartupAUth.cs, Program.cs in a classic asp.net web api project with .net framework 4.5.2?
thanks
Upvotes: 3
Views: 8391
Reputation: 33791
In a classic asp.net web project you will likely find the following locations in the Global.asax.cs
file useful:
1) The Application_Start
method is called once on application start and is useful for configuration code that only needs to run one per web server recycle.
2) The Application_AuthenticateRequest
method is called once for every request and can be useful for authentication code, however be aware that it does not have access to session state.
3) The Application_AcquireRequestState
method is called shortly after Application_AuthenticateRequest
and can be useful for security related logic that needs access to session state.
These three should be able to provide you with the hooks you need to bring the functionality over. However, you won't be able to use the same code as you are using in asp.net core because the architecture and available objects are different between the two platforms. So for example and HttpRequest
object in Asp.Net Core is a different object (defined in a different namespace) than the HttpRequest
object in full framework Asp.Net.
The concepts are similar in many cases (like HttpRequest) which helps with porting code, but it would be a porting exercise as the methods and properties on the objects are not identical.
Upvotes: 5