asp.net-mvc-5

Can't connect to Database to execute Identity functions

夙愿已清 提交于 2020-01-15 03:52:41
问题 I've created a new application with ASP.NET MVC5, using Individual User Accounts for security and Code-First Migrations for the Models/Database modeling. All options are default. I want to setup custom Users and Roles to it, so i created a Seed using RoleManager and UserManager just to populate the Database. It works fine, create 3 Users, 3 Roles and set each User's Role correctly. I can log in to the application correctly. The problem is that i can't execute any Identity method using the

How to send ViewModel and a file in single Ajax POST request, in MVC 5?

妖精的绣舞 提交于 2020-01-14 15:01:13
问题 I have an ASP.NET MVC 5 application. And I'm trying to send a POST request with the Model data, and also include user selected files. Here is my ViewModel (simplified for clarity): public class Model { public string Text { get; set; } public long Id { get; set; } } Here is the controller Action: [HttpPost] public ActionResult UploadFile(long userId, Model model) { foreach (string file in Request.Files) { // process files } return View("Index"); } Html input element: <div> <input type="file"

How to send ViewModel and a file in single Ajax POST request, in MVC 5?

余生长醉 提交于 2020-01-14 15:01:10
问题 I have an ASP.NET MVC 5 application. And I'm trying to send a POST request with the Model data, and also include user selected files. Here is my ViewModel (simplified for clarity): public class Model { public string Text { get; set; } public long Id { get; set; } } Here is the controller Action: [HttpPost] public ActionResult UploadFile(long userId, Model model) { foreach (string file in Request.Files) { // process files } return View("Index"); } Html input element: <div> <input type="file"

Web API Basic Auth inside an MVC app with Identity Auth

自作多情 提交于 2020-01-14 14:12:14
问题 So I have a C# MVC app using Identity for its authentication. I now have a need to expose a few things via Web API to some of my clients. Instead of building a separate app, project, deployment... I've simply added an API Controller to my existing project. To keep things simple for my clients, I've decided to use Basic Auth , opting rather to force my clients into using SSL connections to my API. I've followed this very useful tutorial to implement the Basic Auth in my API: http://www

Web API Basic Auth inside an MVC app with Identity Auth

浪子不回头ぞ 提交于 2020-01-14 14:12:11
问题 So I have a C# MVC app using Identity for its authentication. I now have a need to expose a few things via Web API to some of my clients. Instead of building a separate app, project, deployment... I've simply added an API Controller to my existing project. To keep things simple for my clients, I've decided to use Basic Auth , opting rather to force my clients into using SSL connections to my API. I've followed this very useful tutorial to implement the Basic Auth in my API: http://www

Web API Basic Auth inside an MVC app with Identity Auth

落爺英雄遲暮 提交于 2020-01-14 14:11:49
问题 So I have a C# MVC app using Identity for its authentication. I now have a need to expose a few things via Web API to some of my clients. Instead of building a separate app, project, deployment... I've simply added an API Controller to my existing project. To keep things simple for my clients, I've decided to use Basic Auth , opting rather to force my clients into using SSL connections to my API. I've followed this very useful tutorial to implement the Basic Auth in my API: http://www

Turn off / Disable windows authentication for asp.net-mvc

强颜欢笑 提交于 2020-01-14 09:33:49
问题 I created a new asp.net-mvc project and during setup I chose to use Windows Authentication. Now I like to turn it off(at least for a while). I changed the web.config to this <authentication mode="None" /> But that does change anything. It will still prompt me. I am using the IIS Express. UPDATE: I mean it still prompts me when using Firefox. Internet Explorer will continue and not show my domain username 回答1: The web config should overwrite the IIS express config but in this case it seems it

ASP.NET MVC : Context type not found in assembly

别等时光非礼了梦想. 提交于 2020-01-14 04:53:06
问题 This is my first asp.net mvc project. I used EF code first approach and created a separate class library to write my model and context. I also referenced the class library in mvc project. But now after creating few more new models when I try to enable migration, it gives me an error. I also tried all the possible solutions mentioned here : No context type found in the assembly. ASP.NET MVC4 Still problem remains the same. Am I missing something? This is code for Context Class: using System;

Secure way to Delete a record in ASP.Net MVC

邮差的信 提交于 2020-01-13 18:56:26
问题 I want to delete a product from my ASP.Net MVC 5 website. I want to know if adding [AntiForgeryToken] and [Authorize] is enough to secure the Delete operation? View <p>Delete: @Model.Name</p> @using (Html.BeginForm("Delete", "ProductController", FormMethod.Post, new { ProductId = Model.ProductId })) { @Html.AntiForgeryToken() <button type="submit">Delete</button> } Controller [HttpPost] [Authorize] [ValidateAntiForgeryToken] public ActionResult Delete(long ProductId) { /* Do I need to check

How to Insert to Master-detail tables in ASP.NET MVC 5

柔情痞子 提交于 2020-01-13 18:10:55
问题 I have Orders table and OrderDetails table in DB. With Entity Framework 6 I have obtained a model so I have classes generated from it. I also generated controllers and views from the Orders table. Orders folio (PK) date customer (FK) OrdersDetail folio (FK) -- to the Orders table product (FK) price quantity The generated Create Post action is the following: [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create([Bind(Include = "folio,date,customer")] Orders order) { if (ModelState