asp.net-4.5

How to use OpenID providers with unique identifier URLs in ASP.NET MVC4

不想你离开。 提交于 2019-11-27 11:46:42
问题 The new SimpleMembershipProvider implemented in ASP.NET MVC4 allows easy, built-in support for two popular OpenID providers (Google and Yahoo) and three OAuth providers (Microsoft, Facebook, Twitter). The providers implemented in DotNetOpenAuth.AspNet.Clients for use with the SimpleMembershipProvider all use static URLs for their identity services --- that is, all users use the same well-known URL to access the provider. The users' OpenID identifiers are separate from the URL used to access

Why is my ClaimsIdentity IsAuthenticated always false (for web api Authorize filter)?

让人想犯罪 __ 提交于 2019-11-27 11:45:20
In a Web API project I am overriding the normal authentication process to check tokens instead. The code looks something like this: if ( true ) // validate the token or whatever here { var claims = new List<Claim>(); claims.Add( new Claim( ClaimTypes.Name, "MyUser" ) ); claims.Add( new Claim( ClaimTypes.NameIdentifier, "MyUserID" ) ); claims.Add( new Claim( ClaimTypes.Role, "MyRole" ) ); var claimsIdentity = new ClaimsIdentity( claims ); var principal = new ClaimsPrincipal( new[] { claimsIdentity } ); Thread.CurrentPrincipal = principal; HttpContext.Current.User = principal; } And then later

Understanding context in C# 5 async/await

妖精的绣舞 提交于 2019-11-27 11:23:10
Am I correct that async/await itself has nothing to do with concurrency/parallelism and is nothing more than continuation-passing style (CPS) implementation? And the real threading is performed by SynchronizationContext instance that await passes/restores? If that is correct I have the following question about SynchronizationContext : it guarantees that a continuation will be executed on the same thread. However, are there any guaranties that the thread's context information is persisted? I mean Name , CurrentPrincipal , CurrentCulture , CurrentUICulture , etc. Does it depend on framework (ASP

GlobalConfiguration.Configure() not present after Web API 2 and .NET 4.5.1 migration

巧了我就是萌 提交于 2019-11-27 10:49:19
I recently started following this guide to migrate my project to .NET 4.5.1 and Web Api 2. The very first thing MS developer Rick Anderson asks you to do is change: WebApiConfig.Register(GlobalConfiguration.Configuration); to GlobalConfiguration.Configure(WebApiConfig.Register); in the global.asax file. Yet this is giving me an error when I try to build: Error 1 'System.Web.Http.GlobalConfiguration' does not contain a definition for 'Configure' My project is currently on MVC 5 and Web Api 2 and .NET 4.5.1, yet I think System.Web.Http still thinks it's the .NEt 4.0 version. How can I go about

Using Grunt, Bower, Gulp, NPM with Visual Studio 2015 for a ASP.NET 4.5 Project

老子叫甜甜 提交于 2019-11-27 09:59:07
Visual Studio 2015 comes with built in support for tools like Grunt, Bower, Gulp and NPM for ASP.NET 5 projects. However when I create a ASP.NET 4.5.2 project using Visual Studio 2015 it doesn't use these tools. I'd like to use bower instead of nuget to manage client side packages. I can find information about using these tools with Visual Studio 2013 (see this question for example). But I guess the procedure is different for Visual Studio 2015 since it has built in support for these tools. Robert Hegner While Liviu Costea's answer is correct, it still took me quite some time to figure out how

Writing to ZipArchive using the HttpContext OutputStream

霸气de小男生 提交于 2019-11-27 07:57:55
I've been trying to get the "new" ZipArchive included in .NET 4.5 ( System.IO.Compression.ZipArchive ) to work in a ASP.NET site. But it seems like it doesn't like writing to the stream of HttpContext.Response.OutputStream . My following code example will throw System.NotSupportedException: Specified method is not supported as soon as a write is attempted on the stream. The CanWrite property on the stream returns true. If I exchange the OutputStream with a filestream, pointing to a local directory, it works. What gives? ZipArchive archive = new ZipArchive(HttpContext.Response.OutputStream,

requestValidationMode 4.5 vs 2.0

我的梦境 提交于 2019-11-27 04:25:26
问题 Is there a difference between requestValidationMode="4.5" and requestValidationMode="2.0"? I have a .net 4.5 application, there is a control which I don't want to validate, as users can enter html tags in: <asp:TextBox ID="txtTitle" runat="server" ValidateRequestMode="Disabled" /> in my web.config i have: <compilation debug="true" strict="false" explicit="true" targetFramework="4.5">...</compilation> <httpRuntime targetFramework="4.5" requestValidationMode="2.0" /> initially I have put

User.Identity.IsAuthenticated is false after successful login

我的梦境 提交于 2019-11-27 01:48:07
问题 I need to get the UserId Guid directly after a successful login. The following code doesn't work: if (Membership.ValidateUser(txtUsername.Value, txtPassword.Value)) { FormsAuthentication.SignOut(); FormsAuthentication.SetAuthCookie(txtUsername.Value, true); if (HttpContext.Current.User.Identity.IsAuthenticated) { // doesn't run Guid puk = (Guid)Membership.GetUser().ProviderUserKey; } } The following code does work: if (Membership.ValidateUser(txtUsername.Value, txtPassword.Value)) {

Build ASP.NET 4.5 without Visual Studio on Build Server

喜欢而已 提交于 2019-11-26 22:28:33
问题 Its been a while since I setup a Build Server so maybe I've forgotten something or maybe .NET 4.5 is different from whatever version I did this with last time, but here is my problem. I'm trying to setup a build server to monitor a source control repository. Whenever something changes, I want the server to pull the changes and build the project. If there are no errors, I want to deploy the site to a web site running on the build server. In the past when I did this, I thought that I was able

ASP.NET MVC 4 Areas in separate projects not working (view not found)

谁说我不能喝 提交于 2019-11-26 19:16:06
问题 I have tried to create simple proof-of-concept ASP.NET MVC 4 web site using areas in separate projects. I tried to following tutorials: http://bob.archer.net/content/aspnet-mvc3-areas-separate-projects (Application doesn't work in virtual directory... I use IIS). I hope there is better way than virtual directories. Then I tried this tutorial: http://forums.asp.net/t/1483660.aspx/1 But there is no "AreasManifestDir" element in *.csproj of area project (and got error "The view 'Index' or its