简体   繁体   English

现有的MVC4项目与Winform共享数据

[英]Existing MVC4 Project to share data with Winform

I have an MVC4 internet solution which uses the following setup 我有一个使用以下设置的MVC4互联网解决方案

  • N Tier Application with Repository Design N层应用程序与存储库设计
  • Authentication etc all decoupled from UI and on DAL Layer (Accessed via SecurityRepository) 身份验证等都与UI分离并且在DAL层上分离(通过SecurityRepository访问)
  • Uses SimpleAuthentication in background 在后台使用SimpleAuthentication

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. 我被要求将一个WebAPI项目添加到解决方案中,以便我可以共享数据源,这纯粹是为了内部读取一些数据到Winform应用程序。

Is it possible to still decorate the Controllers in the API with [Authorize] and call the SecurityRepository.Login method to authenticate a winform? 是否仍然可以使用[Authorize]装饰API中的Controllers并调用SecurityRepository.Login方法来验证Winform? Winforms don't use cookies so not sure how I would supply a token and manage access via roles. Winforms不使用cookie,因此不确定我将如何提供令牌并通过角色管理访问。 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. 我希望它在后台进行身份验证,并且没有登录页面,因此对于最终用户而言,它是无缝的,我们已将当前的Winform应用程序数据源切换为指向此WebAPI。

[Edit] [编辑]

For future searchers, look here too: ASP.NET MVC 4 Web API Authentication with Membership Provider 对于将来的搜索者,也请单击此处: 具有成员资格提供程序的ASP.NET MVC 4 Web API身份验证

You will have to change your Authentication for WebApi. 您将必须更改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 在Steves Coding博客上有一篇简单的文章,涉及使用Asp.Net WebAPI进行基本身份验证

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM