Questions tagged [asp.net-mvc-5]

ASP.NET MVC 5 is the fifth major version of the ASP.NET Model-View-Controller platform for web applications.

Features

  • Basic Form Post with a Web MVC Pattern
  • UpdateModel and TryUpdateModel Methods
  • async ActionResults
  • Handling Error Scenarios - Redisplaying Forms with Error Messages
  • Asp.Net Identity (using Code-First Entity Framework)
  • Bootstrap in the MVC template
  • Authentication Filters
  • Filter overrides
  • Attribute Based Routing
15661 questions
401
votes
22 answers

OwinStartup not firing

I had the OwinStartup configuration code working perfectly and then it stopped working. Unfortunately I'm not sure exactly what I did to get it to stop working and am having a really hard time figuring it out. To make sure I have the basics…
Jeff Treuting
  • 13,910
  • 8
  • 36
  • 47
268
votes
21 answers

HTTP Error 500.19 and error code : 0x80070021

I have a simple webAPI build by Visual Studio 2013. It works well when I run it from VS13 but when I copy the project in local IIS it gives me the following error. HTTP Error 500.19 - Internal Server Error The requested page cannot be accessed…
Umar Abbas
  • 4,041
  • 2
  • 23
  • 21
255
votes
11 answers

ASP.NET MVC 5 - Identity. How to get current ApplicationUser

I have an Article entity in my project which has the ApplicationUser property named Author. How can I get the full object of currently logged ApplicationUser? While creating a new article, I have to set the Author property in Article to the current…
Ellbar
  • 3,984
  • 6
  • 24
  • 36
218
votes
8 answers

How to add MVC5 to Visual Studio 2013?

I'm starting a new project, and would like to give a try to MVC 5 (I have built a web app using MVC 4 before). In Visual Studio 2013, I click the New Project and navigate to Visual C# > Web > Visual Studio 2012 (even though I have installed VS 2013…
developer82
  • 13,237
  • 21
  • 88
  • 153
217
votes
4 answers

ASP.NET Identity DbContext confusion

A default MVC 5 App comes with this piece of code in IdentityModels.cs - this piece of code is for all the ASP.NET Identity operations for the default templates: public class ApplicationDbContext : IdentityDbContext { public…
215
votes
3 answers

Do I need a Global.asax.cs file at all if I'm using an OWIN Startup.cs class and move all configuration there?

Let's say for example in a brand new ASP.NET MVC 5 application made from the MVC with Individual Accounts template, if I delete the Global.asax.cs class and move it's configuration code to Startup.cs Configuration() method as follow, what are the…
user681768
213
votes
3 answers

What is ASP.NET Identity's IUserSecurityStampStore interface?

Looking at ASP.NET Identity (new membership implementation in ASP.NET), I came across this interface when implementing my own UserStore: //Microsoft.AspNet.Identity.Core.dll namespace Microsoft.AspNet.Identity { public interface…
Brian Chavez
  • 8,048
  • 5
  • 54
  • 47
212
votes
25 answers

'router-outlet' is not a known element

I have a mvc 5 project with a angular frontend . I wanted to add routing as described in this tutorial https://angular.io/guide/router. So in my _Layout.cshtml I added a and created my routing in my app.module. But when I run this…
Molo
  • 2,143
  • 2
  • 13
  • 11
189
votes
15 answers

Unauthorised webapi call returning login page rather than 401

How do I configure my mvc/webapi project so that a webapi method called from a razor view doesn't return the loginpage when its unauthorised? Its a MVC5 application which also has WebApi controllers for calls via javascript. The two methods…
Tim
  • 7,401
  • 13
  • 61
  • 102
162
votes
9 answers

How to get current user, and how to use User class in MVC5?

How can I get the id of the currently logged in user in MVC 5? I tried the StackOverflow suggestions, but they seem to be not for MVC 5. Also, what is the MVC 5 best practice of assigning stuff to the users? (e.g. a User should have Items. Should…
Adam Szabo
  • 11,302
  • 18
  • 64
  • 100
160
votes
12 answers

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

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…
nzondlo
  • 4,166
  • 4
  • 18
  • 20
156
votes
1 answer

How to add Web API to an existing ASP.NET MVC (5) Web Application project?

Assuming you forgot to tick the Web API checkbox (add it to the project) when making a new MVC (5) project, what do you need to do add Web API and get it working? There are a bunch of migration questions, but none seemed to have the complete and…
lko
  • 8,161
  • 9
  • 45
  • 62
139
votes
6 answers

How to extend available properties of User.Identity

I'm using MVC5 Identity 2.0 for users to log into my website, where the authentication details are stored in an SQL database. Asp.net Identity has been implemented in a standard way as can be found in many online tutorials. The ApplicationUser class…
RobHurd
  • 2,041
  • 7
  • 26
  • 34
137
votes
4 answers

How to implement oauth2 server in ASP.NET MVC 5 and WEB API 2

First I'll sketch my project: For my internship I need to add functionality to an existing system. A 3rd party client must be able to access data from AX Webservices once he is authorised by the user via OAuth2. I understand that I need to make a…
Robin
  • 2,704
  • 7
  • 30
  • 47
133
votes
12 answers

MVC 5 Access Claims Identity User Data

I am developing an MVC 5 web application using Entity Framework 5 Database First approach. I am using OWIN for the authentication of Users. Below shows my Login method within my Account Controller. public ActionResult Login(LoginViewModel model,…
tcode
  • 5,055
  • 19
  • 65
  • 124
1
2 3
99 100