asp.net-mvc-5

Can I pass an object from Angular2 to an MVC5 Post?

◇◆丶佛笑我妖孽 提交于 2020-01-05 04:26:08
问题 I am trying to pass my object from Angular2 through a post to an MVC Controller. I was hoping I could pass the actual object in, but all of my properties are appearing as null when it gets into my controller. Is it possible to pass the entire object in? I also tried with "UrlSearchParameters" but it didnt work either. Here's my controller post function: [HttpPost] public JsonResult AddClient(Models.Client client) { var cli = new Models.Client(); cli.name = client.name; cli.npi = client.npi;

Instantiate Identity ApplicationUserManager in Class Library

房东的猫 提交于 2020-01-05 01:44:32
问题 One of the things I do not like about Identity is that the UserManagers have to be instantiated in the controller that you wish to get user information for. In my project, I moved all the business logic into a DAL class library and wanted the Identity to be there as well. I have already moved all the identity classes into the DAL class library (ApplicationRole, ApplicationUser, ApplicationRoleManager, ApplicationSignInManager, ApplicationUserManager, EmailSerivce, SmsService) My DataContext

Issue when deploying an ASP.NET MVC + LocalDB application

久未见 提交于 2020-01-04 13:36:34
问题 I have deployed my ASP.NET MVC 5 application on a server but it crashes on every page using the localdb. Yet I copied the App_Data folder where the .mdf file is located. And I even installed SQL Server 2012 Express on the machine. Nevertheless every time I get the same error. Le fichier spécifié est introuvable Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated

Securing Cookies for Default MVC 5 Application

纵饮孤独 提交于 2020-01-04 02:52:30
问题 I've started a new MVC 5 application in VS2013 (with Authentication = Individual User Accounts in the wizard). I'm looking at my web.config file and it says: <authentication mode="None" /> However, I can clearly create an account and login to my site. So this is a little bit of a mystery. I have read that if I were using forms authentication, that I would need to mark my cookies SSL-only for my site to be secure (just got SSL working yesterday). Is there an analogous step if my authentication

Web API action not found when optional parameter not present in URL

℡╲_俬逩灬. 提交于 2020-01-04 02:48:10
问题 please help. I had to change routing for Web API to be able to use methods in URL: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // for MVC controllers routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Editions", action = "Index", id = UrlParameter.Optional } ); // for Web API routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/

asp.net MVC - How can I share the same instance of a SqlConnection through different repository classes

喜欢而已 提交于 2020-01-04 01:27:31
问题 I'm creating a new project using MVC5 and plain ADO.NET (just as a learning exercise) and I need to create a repository that registers a model with several related objects that also need to be created at the same time and those objects in turn may need to insert other objects. The easiest solution I can think of is to have a massive method(in the repository) that receives an instance of the parent object(which contains all the related objects that needs to insert) and also have a single

asp.net MVC - How can I share the same instance of a SqlConnection through different repository classes

孤街浪徒 提交于 2020-01-04 01:27:08
问题 I'm creating a new project using MVC5 and plain ADO.NET (just as a learning exercise) and I need to create a repository that registers a model with several related objects that also need to be created at the same time and those objects in turn may need to insert other objects. The easiest solution I can think of is to have a massive method(in the repository) that receives an instance of the parent object(which contains all the related objects that needs to insert) and also have a single

ASP.NET Identity update column type for primary key Id in AspNetUsers table from a string to and int or a guid, yes or no?

二次信任 提交于 2020-01-04 00:14:52
问题 Today I read about the new features in ASP.NET Identity 2.0 alpha. http://blogs.msdn.com/b/webdev/archive/2013/12/20/announcing-preview-of-microsoft-aspnet-identity-2-0-0-alpha1.aspx Apparently the possibility to use and int or a guid as the primary key for the AspNetUsers table was added after numerous post/questions on stackoverflow. I started using ASP.NET Identity when the RTM was announced. Since then I have been using the default string ( nvarchar(128) ) type for the Id column in the

Method not found: 'System.Net.Http.HttpRequestMessage System.Web.Http.Controllers.HttpActionContext.get_Request()'

只愿长相守 提交于 2020-01-03 16:59:45
问题 I have created One Filter Attribute public class AuthFilterAttribute : System.Web.Http.Filters.ActionFilterAttribute { public AuthFilterAttribute() { } public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext) { } } I have registered this filter inside the global.asax.cs . When I am trying to call my web API using Postman it is showing the error: Method not found: 'System.Net.Http.HttpRequestMessage System.Web.Http.Controllers.HttpActionContext.get

MVC 5 HttpErrors + Controller/Action

北城以北 提交于 2020-01-03 08:32:13
问题 How can I change error path to my controller/action with httpErrors ? I have this code: <httpErrors errorMode="Custom"> <remove statusCode="404"/> <error responseMode="ExecuteURL" statusCode="404" path="Error/HttpRequestError"/> </httpErrors> But it doesn't work. Empty page shows and action not entered. What i do wrong? P.S. I know about another way to sovle custom page errors. But i want try to use it. Thanks! 回答1: I resolve a problem. This code of web.config works: <httpErrors errorMode=