asp.net-mvc-5

A first chance exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll

狂风中的少年 提交于 2019-12-07 06:13:04
问题 I am trying to call a stored procedure using entity framework 6. I get an error on the output message. A first chance exception of type 'System.Data.Entity.Core.EntityCommandExecutionException' occurred in EntityFramework.SqlServer.dll using (var context = new PartnerPortalEntities2()) { var outputParameter = new ObjectParameter("result", typeof(string)); var spresults = context.assignRoles_CreateAccountAndContacts(user.Id, role, user.AccountId, user.AccountName, user.ContactId, user

How to force only anonymous access to controller action?

戏子无情 提交于 2019-12-07 05:54:10
问题 I can use the [AllowAnonymous] attribute to permit a user to access a controller action, but is there an attribute to permit only anonymous users to an action? e.g. [AllowAnonymousOnly] 回答1: No. It doesn't exist. However, you can create it by creating your own attribute inheriting from the AuthorizeAttribute. Here's an example. Yours would look like: public class AllowAnonymousOnlyAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { // make

Web API 2 project and MVC 5 Website project in same domain

纵饮孤独 提交于 2019-12-07 05:35:52
问题 Technologies used: BreezeJS OData Web API 2 MVC 5 IDE: Visual Studio 2013 I've been wrestling with the idea of having a Web API project and a separate web site project in a single solution. My Web API 2 project opens up as: localhost:2020/ExampleProject.API My MVC 5 WebSite project opens up as: localhost:5050/ExampleProject.WebSite Now by default web api doesn't allow cross origin policies. So I played around with enabling CORS in my Web API 2, although I was able to get it to work, it only

Is really QueryString case insensitive?

随声附和 提交于 2019-12-07 05:08:12
问题 I am working on a payment platform and, in response to a payment, a simple GET call, with some params in the query string, is made to my listener: http://localhost/mytest/listener?TIMECREATED=04.08.2015+12%3A22%3A27&statoattuale=OK&PREVIOUSSTATE=IN&CURRENTSTATE=payment_approved&tipomessaggio=PAYMENT_STATE& DESCRIZIONE =CAMBIO+DI+STATO&datacreazione=04.08.2015+12%3A22%3A27& stabilimento =xxxxxx& MerchantNumber =xxxxxx& descrizione =CAMBIO+DI+STATO&OBJECT=PAYMENT&TIMEGENERATED=04.08.2015+12

Is it possible to get the View name from within Layout?

你。 提交于 2019-12-07 04:57:35
问题 I'm trying to pull the name of the current View from within my Layout. Usually, VirtualPath is used for this. Unfortunately, this will return the path of the Layout file. Is there any way to get the name of the View that's returned by the controller? 回答1: The following will get you the view name: ((RazorView)ViewContext.View).ViewPath; 回答2: You can use ViewBag. Define a CurrentView property to it and use that. public ActionResult Create() { ViewBag.CurrentView = "Create"; return View(); } And

Model with collection - Html.ListBoxFor doesn't set selected items

萝らか妹 提交于 2019-12-07 04:48:27
This one is driving me crazy and before I loose my sane please help. Summary of the issue: My model "Thread" has collection of "ForumMessage", each ForumMessage has one Multi select drop down list. All I want to do is set the selected value based on values coming from Database. I have gone thru many threads but wasn't able to find the solution. In case if you are aware of any such question please let me know and I will go thru them. Below are my models public class Thread { public List<ForumMessage> Messages { get; set; } //Master list coming from DB public List<Classifications>

what are the differences between [DataType(DataType.EmailAddress)] & [EmailAddress]

≡放荡痞女 提交于 2019-12-07 03:35:45
问题 I am trying to understand what are the main differecnes between using [DataType(DataType.EmailAddress)] & [EmailAddress] . inside a model class:- public class MYViewModel { [DataType(DataType.EmailAddress)] OR [EmailAddress] public string Email { get; set; } i did a test and the two attributes will do the following:- will prevent users from adding invalud email address will display the value as "EmailTo:..." but i can not find any differences in respect to the functionality , of course if i

How to add new Scaffold used in Visual Studio 2013 Scaffolding?

こ雲淡風輕ζ 提交于 2019-12-07 02:40:55
问题 Is there a way to add a new Scaffold or override the Scaffolding functionality used in the new Visual Studio 2013 Scaffolding? The only documentation I can find on the internet is how to override the T4 templates using the CodeTemplates folder. I want to add a new Scaffold to the list when Add... > New Scaffold Item... It looks like in Visual Studio 2013 this has been rolled into a library (Microsoft.AspNet.Scaffolding.Mvc.5.0.dll) and registered in the GAC or as a VS Extension. http:/

Are all phases of an ActionFilterAttribute guaranteed to be called?

喜你入骨 提交于 2019-12-07 02:16:04
问题 In writing this answer, I was asked if there are guarantees about the behaviour of the ActionFilterAttribute. and I was unable to answer with confidence. In particular, are all four of the methods OnActionExecuted , OnActionExecuting , OnResultExecuted & OnResultExecuting guaranteed to be called for all requests that pass through the attribute, or are there circumstances (such as exceptions, dropped connection etc) where one or more of the phases might not fire? 回答1: No they are not

How to send AntiForgeryToken (CSRF) along with FormData via jquery ajax

对着背影说爱祢 提交于 2019-12-07 01:09:39
问题 So I want to POST fileUpload along with AntiForgeryToken via AJAX. Here's my code : View @using (Html.BeginForm("Upload", "RX", FormMethod.Post, new {id = "frmRXUpload", enctype = "multipart/form-data"})) { @Html.AntiForgeryToken() @Html.TextBoxFor(m => m.RXFile, new {.type = "file"}) ...rest of code here } <script> $(document).ready(function(){ $('#btnRXUpload').click(function () { var form = $('#frmRXUpload') if (form.valid()) { var formData = new FormData(form); formData.append('files', $(