MVC4 Source和VS2010(MVC4 Source and VS2010)
背景:
根据http://aspnetwebstack.codeplex.com/documentation上的文档(在“获取和构建代码”下,第一个项目说:
The easiest way to work with our source is to install Visual Studio 2010 (with SP1).
我正在运行VS2010 SP1,并设法按照所有说明启动并运行此源代码(在我的Win7 64位计算机上)。 我安装了.NET 4.5框架。
问题:
在构建期间(从命令行)以及从Visual Studio本身,我收到以下错误:
"The project file 'MY_LOCAL_PATH\src\System.Net.Http.Formatting.NetCore\System.Net.Http.Formatting.NetCore.csproj' cannot be opened. The project type is not supported."
有谁知道如何加载这个项目? Runtime.sln中的所有其他加载正常。
更新:
项目文件(csproj)中的两个项目类型guid是
BC8A1FFA-BEE3-4634-8014-F334798102B3
和FAE04EC0-301F-11D3-BF4B-00C04F79EFBC
。 第一个与Metro有关,另一个是C#。 我可以理解地铁挂断,但文档说VS2010 SP1还不错。Background:
According to the documentation at http://aspnetwebstack.codeplex.com/documentation (under 'Getting and Building the Code' the very first item says:
The easiest way to work with our source is to install Visual Studio 2010 (with SP1).
I am running VS2010 SP1 and have managed to follow all of the instructions to get this source code up and running (on my Win7 64 bit machine). I am have the .NET 4.5 framework installed.
Problem:
During the build (from the command line) as well as from Visual Studio itself, I get the following error:
"The project file 'MY_LOCAL_PATH\src\System.Net.Http.Formatting.NetCore\System.Net.Http.Formatting.NetCore.csproj' cannot be opened. The project type is not supported."
Does anyone know how to get this project to load? All of the others in the Runtime.sln load fine.
UPDATE:
The two project type guids that are in the project file (csproj) are
BC8A1FFA-BEE3-4634-8014-F334798102B3
andFAE04EC0-301F-11D3-BF4B-00C04F79EFBC
. The first has something to with Metro and the other is C#. I could understand the metro hangup but again the documentation says VS2010 SP1 is fine.
原文:https://stackoverflow.com/questions/12412123
最满意答案
我没有找到一个很好的方法来做到这一点。 我没有使用
:omniauthable
,我正在单独使用OmniAuth和Devise,如Railscast中所见,其中有两个表users
和authentications
。 这有点hacky只适用于Facebook。基本上,通过SSL或类似的方式将您的access_token从iPhone发送到服务器。 您必须首先检查OmniAuth,如果您被授予访问权限,那么您可以通过以下方式手动创建与OmniAuth的会话:
尽管如此,我确实得到了一些工作:
FB = OmniAuth::Strategies::Facebook.new("nothing") client = ::OAuth2::Client.new("nothing", "nothing", FB.client_options) cached_token = "app_id_part|session_id_part|token_part" # or maybe you sent it from the iPhone access_token = ::OAuth2::AccessToken.new(client, cached_token) FB.instance_variable_set("@access_token", access_token) FB.auth_hash # You will either get a hash or get this error: # OAuth2::AccessDenied: Received HTTP 401 during request.
之后,您可以通过Authentications表查找查找用户所需的用户信息:
@user = Authentication.where(:uid => FB.auth_hash["uid"], :provider => "facebook").first.user
现在我们创建一个会话:
sign_in_and_redirect(:user, @user) # or, perhaps sign_in(@user, :bypass => true)
I have not found a good way of doing this. I am not using
:omniauthable
either, I'm using OmniAuth and Devise separately as seen in the Railscast episode where there are two tablesusers
andauthentications
. It's kinda hacky and only works for Facebook.Basically, send your access_token from the iPhone to the server over SSL, or something similar. You have to check with OmniAuth first and if you are granted access, then you can manually create a session with OmniAuth by going something like:
I did get something to work by doing this though:
FB = OmniAuth::Strategies::Facebook.new("nothing") client = ::OAuth2::Client.new("nothing", "nothing", FB.client_options) cached_token = "app_id_part|session_id_part|token_part" # or maybe you sent it from the iPhone access_token = ::OAuth2::AccessToken.new(client, cached_token) FB.instance_variable_set("@access_token", access_token) FB.auth_hash # You will either get a hash or get this error: # OAuth2::AccessDenied: Received HTTP 401 during request.
After that you lookup the user info you need to find the user via your Authentications table:
@user = Authentication.where(:uid => FB.auth_hash["uid"], :provider => "facebook").first.user
Now we create a session:
sign_in_and_redirect(:user, @user) # or, perhaps sign_in(@user, :bypass => true)
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
是的,当你添加before_filter :authenticate_user!时,Devise会在你的控制器和视图中使用current_user帮助方法before_filter :authenticate_user! 到您的控制器。 这在文档中有更详细的解释。 Yes Devise will make the current_user helper method available in your controllers and views when you add before_filter :aut ...
-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
选项1:我能想到的最简单的方法是在JS中包含accessToken并通过ajax调用传递它。 选项2:与选项1一样使用,但不发送accessToken,而是发送signedRequest。 在服务器端,你可以使用( TryParseSignedRequest方法)解码它,它会给你UserID :-) 注意: signedRequest使用应用程序Secret进行加密。 你是唯一一个应该知道它的人,所以你在这方面是安全的。 免责声明: 我在C#中没有编码经验,但在谷歌的一个小搜索给了我这个: Facebook ...
-
终于弄明白了; 这是其他人有同样问题的答案。 相关的登录过程发生在Devise的Rememberable模块中。 Devise在remember_user_token cookie中的会话之间存储已保存的用户信息。 Cookie包含用户ID和记忆令牌。 如果电子邮件和密码都为空,则记住令牌也将为空,导致内部设计比较(secure_compare)失败。 这将导致会话丢失并且remember_user_token cookie将被销毁。 要解决此问题,您可以为没有密码的用户设置临时密码。 一种方法如下。 cl ...
-
我上面描述的方法很有效。 以下是摘要: Facebook通过iPhone应用程序连接 检索手机上的fb访问令牌 将fb访问令牌发送到Rails服务器 您正在使用的控制器将检查fb参数并查询用户信息 控制器的外观示例 if params[:fb_access_token] @graph = Koala::Facebook::GraphAPI.new(params[:fb_access_token]) @me = @graph.get_object("me") if profil ...
-
欺骗facebook应用ID(Spoofing facebook app ID)[2024-04-14]
总之,对于所有正在考虑这一点的人来说 - 确实没有办法阻止客户端ID被欺骗。 这是开发人员不愿意在本机应用中使用OAuth隐式流的原因之一,正如Andre D在https://stackoverflow.com/a/17439317/5154090中指出的那样: 不推荐使用隐式流与本机应用程序。 (请参阅https://tools.ietf.org/html/draft-ietf-oauth-native-apps-09#section-8.5 )。 在实践中,如果有人发起这种攻击,那么用户将下载应用程序A ... -
我没有找到一个很好的方法来做到这一点。 我没有使用:omniauthable ,我正在单独使用OmniAuth和Devise,如Railscast中所见,其中有两个表users和authentications 。 这有点hacky只适用于Facebook。 基本上,通过SSL或类似的方式将您的access_token从iPhone发送到服务器。 您必须首先检查OmniAuth,如果您被授予访问权限,那么您可以通过以下方式手动创建与OmniAuth的会话: 尽管如此,我确实得到了一些工作: FB = Omni ...
-
你应该使用facebook PHP SDK: https : //github.com/facebook/php-sdk/ 请参阅示例文件,以免丢失... https://github.com/facebook/php-sdk/blob/master/examples/example.php Facebook图形API有点烦人......所以使用它会更容易(至少对我而言) You should use facebook PHP SDK: https://github.com/facebook/php-sdk ...
-
弄清楚了。 除了Omniauth.rb之外,您还需要确保编辑Devise.rb Devise.rb应该有: config.omniauth :facebook, "your_facebook_id", "your_facebook_secret", scope: 'email,public_profile', info_fields: 'email, first_name, last_name' 替换你需要的任何特定info_fields( 这里有所有可用的列表) Figured it out. You ...