Authenticating an Asp.Net Mvc4 Project to Another Asp.Net Webapi Project Supported by SQL Server CE 4

I have been looking for the answer to my question for some time, but I can not find what I was looking for, so I hope someone can help me :)

Scenario:

3 Projects:

  • Asp.net Web Api Project (SQL Server CE 4 Database + Asp.Net Membership)
  • Windows Phone 7.5 application (authenticates SQL Server CE database with REST)
  • Asp.net MVC 4 project (which wants to contact the same SQL Server CE database, also using REST)

Authentication of WP7 applications is already working. But I'm having trouble trying to figure out how to allow my MVC application to authenticate with the same SQL Server CE database.

I can probably create my own controls and use the same authentication logic that I used in the WP7 application, but I want to keep the existing functionality that the [Authorize] attribute offers.

So my question is:

how can I let my MVC project authenticate through the Web Api project and still support functions that when a user tries to access a page that needs authentication, it will be redirected to the login page and such

Hope my question is clear enough! If not, feel free to ask additional questions!

Yours faithfully,

Gert

+4
source share
1 answer

Well, after some rest and some logical thinking, I just realized that I had to change the login method of the AccountController in the MVC project.

I cannot provide any code because I am not on my computer, but it is just an authentication code that you would use elsewhere. For example, using REST authentication or authentication through the WCF service.

Yours faithfully,

Gert

0
source

Source: https://habr.com/ru/post/1436798/


All Articles