1

I have an MVC4 internet solution which uses the following setup

  • N Tier Application with Repository Design
  • Authentication etc all decoupled from UI and on DAL Layer (Accessed via SecurityRepository)
  • Uses SimpleAuthentication in background

I have been asked to add a WebAPI project to the solution so I can share the datasource, purely for reading some data out to a Winform application internally.

Is it possible to still decorate the Controllers in the API with [Authorize] and call the SecurityRepository.Login method to authenticate a winform? Winforms don't use cookies so not sure how I would supply a token and manage access via roles. I want it to authenticate in the background and not have a login page, ideally seamless to the end user we have switched the current Winform app datasource to point to this WebAPI.

[Edit]

For future searchers, look here too: ASP.NET MVC 4 Web API Authentication with Membership Provider

4

1 回答 1

0

You will have to change your Authentication for WebApi. The easiest way is to implement token autentication. There is a simple article on Steves Coding Blog about Basic Authentication with Asp.Net WebAPI

于 2013-06-17T09:07:44.107 回答