在winforms程序中利用ASP.NET中使用的用户身份 [英] Utilize useridentity used in ASP.NET in a winforms program

查看:65
本文介绍了在winforms程序中利用ASP.NET中使用的用户身份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要连接并验证asp.net网站并将程序winforms到mysql数据库。是否可以使用ASP.net这样做,但我如何在winforms上做到这一点?我在vb.net中编码



我尝试过:



用疯狂的谷歌搜索。在app.config中添加了连接设置和提供商设置



在winforms上使用登录代码苦苦挣扎

I need to connect and authenticate an asp.net website and winforms programs to a mysql database. Was able to do so with ASP.net but how do I do that on winforms? I code in vb.net

What I have tried:

Googled like crazy. Added the connection settings and provider settings in app.config

Struggling with login code on winforms

推荐答案

这可能比您想象的要复杂得多:如果MySql数据库是您的托管服务的一部分,那么您不太可能直接从WinForms应用程序访问它,因为这需要数据库公开可用 - 而且出于安全原因这种情况很少见。



首先,找到数据库,然后检查是否可以通过开发PC的数据库管理系统访问它。如果可以的话,那么你可以在你的应用程序中使用连接字符串(或者至少是连接字符串所需的详细信息)。



如果没有不...它变得复杂了。您可以尝试让您的托管服务允许远程访问数据库,但这既危险(因为它对任何想要它的人开放,连接详细信息将在您的应用程序代码中)并且不安全。它也不太可行。

另一种方法是尝试编写一个Web服务,根据您的非公共数据库为您验证用户身份,将其发布到您的托管服务,并从您的新应用程序访问它。看看我的意思可能比你想象的更复杂?



祝你好运!
That's possibly more complicated than you think: if the MySql DB is part of your hosting service, then it's pretty unlikely that you can access it directly from a WinForms app as that requires that the DB be publically available - and that's rare for security reasons.

So start by "finding" the DB, and checking if you can access it via a DB management system from your dev PC. If you can, then that gives you a connection string (or at least the details you need for the connection string) you can use in your app.

If it doesn't ... it gets complicated. You could try asking your hosting service to allow remote access to the DB, but that's both dangerous (in that it's open to anyone who wants it, and the connections details will be in your app code) and insecure. It's also unlikely to work.
The other alternative is to try writing a web service which authenticates users for you against your non-public DB, publishing that to your hosting service, and accessing that from your new app. See what I mean about "possibly more complicated than you think"?

Good luck!


这篇关于在winforms程序中利用ASP.NET中使用的用户身份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆