asp.net-mvc-5

How to get 'System.Web.Http, Version=5.2.3.0?

我是研究僧i 提交于 2019-12-17 17:53:07
问题 I just created an MVC5 project and added several packages from nuget, but then when I compiled the project, i got this error. It seems one of the packages really depends on system.web.http version 5.2.3.0, which i couldn't find anywhere. I just wonder how to get the latest version of system.web.http ? Error 2 Assembly 'System.Web.Http.WebHost, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses 'System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken

Access Claim values in controller in MVC 5

[亡魂溺海] 提交于 2019-12-17 17:39:37
问题 I have used OWIN authentication in my application. Login Action var claims = new List<Claim>(); claims.Add(new Claim(ClaimTypes.Name, result.UserFirstName)); claims.Add(new Claim(ClaimTypes.Sid, result.UserID.ToString())); var identity = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie); I want to access the UserName and UserID from different action. How can I access the values which is added in the claims? Update I have tried var claims = new List<Claim>(); claims.Add

Asp.net identity entity framework database first approach with own table defintion

梦想的初衷 提交于 2019-12-17 16:54:31
问题 I have below four tables Role table User table UserRole table UserType table default Asp.net identity having below tables like Asp.netusers,Asp.netRoles,Asp.netuserlogins,Asp.netuserclaims,Asp.netuserroles My table doesn't match the same column name and some columns not available in my tables. can i use my own tables to utilize the feature of asp.net identity or else i need to follow the same columns used in Asp.netusers table to my User table. Is that all columns necessary to add in my table

Invalid object name 'dbo.AspNetUsers' in Asp.NET MVC 5 Entity Framework

爱⌒轻易说出口 提交于 2019-12-17 16:29:13
问题 If you have an existing database, and if you want to include ASP.NET Identity tables to it, you can face this error. Also in the beginning, you may not know how to integrate [AspNetRoles], [AspNetUserClaims], [AspNetUsers], [AspNetUserLogins] tables into your existing database. Although there are a lot of resources about this topic, this answer tries to be short and to the point. You may want to use the Database-First approach in Entity Framework together with the ASP.NET Identity feature of

ASP.NET MVC Routing based on domain & hostname

本秂侑毒 提交于 2019-12-17 16:28:39
问题 I am new to ASP.NET MVC, most of my experience is on ASP.NET Webforms. Is there a way to setup routing based on domain/hostname, i.e. www.domain.com goes to one area, admin.domain.com to another and www.differentdomain.com to yet another area all on the web application. Also, is there a way to do a catch-all i.e. *.domain.com will be routed to another area? 回答1: you can use Domain Routing mapping routes.Add("DomainRoute", new DomainRoute( "{customer}.example.com", // Domain with parameters "

Can I run MVC 5 application on .NET Framework 4.0?

百般思念 提交于 2019-12-17 16:26:45
问题 I have my MVC 5 application that I create in VS 2013. Now I'm trying to deploy this application and I have a question: Can I deploy MVC 5 on the server with 4.0 .Net Framework? I just create Deploy Package and I have tried to import this package in IIS. It says "Import success", but when I try to "Browse" Web Site It says: HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. I just checked Directory Browsing and it's Enabled in IIS 回答1: Nope,

Can't create new MVC5 project or any other ASP .NET projects in Visual Studio 2013

拟墨画扇 提交于 2019-12-17 16:11:25
问题 When I attempt to create a new MVC5 project, I get a template selection dialog that doesn't load any options. I am unable to select a project type (ex. MVC, Web forms, Web API) and create the project. It appears like this: http://i.imgur.com/OVLZfSj.png To produce this issue, I go to File -> New Project -> Visual C# -> Web -> ASP .NET Web Application After clicking OK, the point where I select the ASP .NET project template I want just sits there empty. I am running Visual Studio 2013 Ultimate

What / why is Roslyn “needed” in /bin folder of Asp.Net

假如想象 提交于 2019-12-17 15:53:14
问题 There are a bunch of related questions on this, though most of the answers define Roslyn and/or provide a "fix" to some issue ( exe , with hosting providers, etc.) What I can't seem to track down is the "why" and "what for" (perhaps only in the context of ASP.Net MVC/Web API) in /bin/roslyn . I ran in to similar issues (hosting - .exe restrictions, support for 4.6 , etc.) and my "fix" was to "just deploy to Azure" (of course everything works without a hitch). But really, this doesn't answer:

MVC ViewModel example

大兔子大兔子 提交于 2019-12-17 15:40:08
问题 I've been doing tutorials and trying to learn best practice when it comes to MVC development. The design I'm using below comes from Pro ASP.Net MVC5 by Apress/Adam Freeman. So far, everything is coming along good...but I still have not completely come to grip on working with Controllers. Yes, I understand the concept of Controllers, but still struggle when it comes to post and get methods. Here is the flow of my sample MVC application: My app.Domain project I have a user table in the database

How to know when OWIN cookie will expire?

北战南征 提交于 2019-12-17 15:37:07
问题 I would like to create some kind of countdown timer based on the time the OWIN cookie will expire. I am using OWIN with MVC 5 and from what I understand SlidingExpiration is on by default. I do not use 'session' as I need this app to live within a web farm (I dont plan on deploying a session database). 回答1: All you need is to get hold of the CookieValidateIdentityContext during the cookie validation stage. Once you get it, extract whatever you need and keep them as Claim or some other way