asp.net-mvc-5

How to enable CORS in Asp.Net MVC5

时间秒杀一切 提交于 2019-12-11 15:59:02
问题 I am running Angular 6 in my local and getting CROS error when invoking MVC controller action method. I tried to fix this by adding below line of code in my .net application's web.config file. But still getting same error. <httpProtocol> <customHeaders> <clear /> <add name="Access-Control-Allow-Origin" value="*" /> </customHeaders> </httpProtocol> </system.webServer> I do not want to run a browser by disabling web security also I do not want to create a class since only to run in my local I

How to make an ajax dropdown strongly bound to the ViewModel in ASP.Net MVC 5

左心房为你撑大大i 提交于 2019-12-11 14:58:54
问题 So, I have a referral form for job application. Now when a job seeker selects a company from a company dropdown, I want to display the dropdown of coverletters just for that company (coverletters are already uploaded by candidate from another tab). Now for getting referred for Microsoft a person might have 3 coverletters. Issue: I want to know how to can I display the dropdown from ajax call and still keep the coverletter dropdown strongly bound to the Model . Below is Non AJAX strongly Bound

Why my MVC 5 ASP.Net App Works Locally but not when Deployed to Azure?

为君一笑 提交于 2019-12-11 14:36:48
问题 My first question here, I hope someone can help me out. I'm new to developing ASP.Net applications and have recently completed a small project based around racing drivers, teams etc which works fine locally but not when I've deployed it to Azure. First issue I noticed was that the CSS didn't load on the deployed version. The default pages, Home, About and Contact all work fine (though without my styling) but the ones I created myself off my models return an error page saying only Error. An

MVC5 Azure AD IDX21323

泪湿孤枕 提交于 2019-12-11 14:32:08
问题 My Azure Free subscription has expired. I've since been added to my companies Azure subscription but I can no longer use SSO with Oauth2 using AD. VS2017 reports 0 subscriptions and when I go to Manage my subscription is listed, but I cannot enable it "This subscription is not supported by server explorer." I'm assuming that I need to update something on our companies Azure subscription at this point, but I don't know what to request from management as far as subscription updates. This worked

return url.action as json object mvc

自古美人都是妖i 提交于 2019-12-11 13:58:39
问题 My Controller method returns Json object which has url formed as shown below : return Json(new { url = Url.Action("ShowContact", "Customer", new { vm = contactVM }) }, JsonRequestBehavior.AllowGet); In the ajax call's success code, I want to assign this url to window.location.href so I can redirect to view as per url formed. But return value of ajax call shows plain text value for route value passed as part of url. Hence, I'm not getting whatever route value I want to pass to the redirect

Double input mvc extension

风格不统一 提交于 2019-12-11 13:52:19
问题 Here I was trying to make an extension with double input boxes the returned model's properties are null, They are not correctly bound or there is another issue here, please help me on writing this extension and make use of it. I need to use thousands of it during my code. public static class DoubleBoxHelper { public static MvcHtmlString DoubleBoxFor<TModel, TProperty>( this HtmlHelper<TModel> htmlHelper, //int id, Expression<Func<TModel, TProperty>> expression) { var builder = new

Cannot add view to ASP.NET MVC 5 project

不想你离开。 提交于 2019-12-11 13:49:01
问题 I'm trying to add a view to an ASP.NET MVC 5 project in Visual Studio 2013, but the Add button is greyed out. 回答1: I got this for ages, all I did was upgrade the nuget packages for Mvc and it fixed it. I suspect that I had a mismatch of versions in the solution. Update-Package Microsoft.AspNet.Mvc -Version 5.2.3 The version part is optional, but it should mean that all projects get the same version. 回答2: Different from the OP issue (as I'm on VS2017) but in case anyone else comes to this

How do I update a password that's in a different format from the defined model? I'm getting DbEntityValidationException

我们两清 提交于 2019-12-11 13:42:22
问题 The Problem I have a pre-defined [StringLength()] and [RegularExpression()] constraint on my Code-First Model. The [StringLength()] requirement is 8-16 characters The [RegularExpression()] constraint for the password is in a different format from the encrypted password. The password is encrypted before being shoved into the database. The encrypted password is 70 characters in length, which is higher than the 8-16 character limit defined in the Model. I am required to use e.Encrypt() , meaning

ASP.NET MVC 5 dynamic controller routes

青春壹個敷衍的年華 提交于 2019-12-11 13:38:48
问题 I'm having a challenge figuring out the best way to define my hierarchical based routes dynamically. I'm looking to achieve database driven links similar to the below: /Illinois/ /Illinois/Chicago/ /Illinois/Chicago/Id /California/ /California/Los-Angeles/ /California/Los-Angeles/Id /New-York/ /New-York/New-York-City/ /New-York/New-York-City/Id And so on, I don't want to have to define a controller for each state, but I'm not 100% against if if it's "the right way". 回答1: You can create a

How to check user role in MVC 5 identity?

一世执手 提交于 2019-12-11 13:33:52
问题 I create a EF code first database identity system with custom roles. When i register a user i put him in a role, and in the database i can see that works on the AspNetUserRoles table. But when i try to check the user role using User.IsInRole("admin") i.e, it always return false( i tried with low, upper, all the way case). I need to put something in the webconfig? Or what im missing here? Its my first time developing with this new Identity system and i think that is a bit confuse. In my