asp.net-mvc-5

Failing to pass data from view to the Action by Html.BeginForm()

两盒软妹~` 提交于 2019-12-02 13:48:09
问题 I am very new at asp.net mvc, so the reason behind my failure might be something basic as well, but I can't seem to find it after nearly a days work now. What I am trying to do is to get the edited Model from the Index view and pass it to a second action which does not have view and returns return RedirectToAction("Index") in the related controller. In OrdersItemsController my Action is as the following: [HttpPost] [ValidateAntiForgeryToken] public ActionResult MarkedShipped(IEnumerable

Site wont start on local using ApplicationPoolIdentity, only when using NetworkService: “HTTP Error 503. The service is unavailable.”

故事扮演 提交于 2019-12-02 13:31:09
I started this question in the hopes of getting some help from the community, but in the process of fully explaining and detailing my problem it seems I've managed to solve it, in what seems to be a legit non hackish way (please tell me if I'm wrong), so I'm going to keep it here in the hopes that it will help others. QUESTION I'm in the process of upgrading my Visual Studio 2010 .NET 4 MVC4 site to Visual Studio 2013 .NET 4.5 MVC5. The site runs fine when using the Visual Studio IIS, but when I switch it over to Windows IIS and set the user to ApplicationPoolIdentity and start the site, I get

nUnit testing a controller extension method

对着背影说爱祢 提交于 2019-12-02 13:24:55
UX controls framework I'm using requires an extension method on MVC controllers. A null object reference is thrown when nUnit tries to call that method (used in order to package a partial view into Json). The author of the framework suggested calling that method through an interface, however that just postpones the null error. Is there a way to test the ActionResult from a controller that uses an extension method? The Controller Create() method returns the resulting partial from the extension method: return Json(new { Content = viewRender.RenderPartialView(this, "ListItems/SimpleSyllabi", new[

How to get the id of selected radio button in Razor code?

爱⌒轻易说出口 提交于 2019-12-02 12:59:18
问题 I have three radio buttons on my HTML form i.e. <input type="radio" name="radioBtn" id="rdBtn1" /> <input type="radio" name="radioBtn" id="rdBtn2" /> <input type="radio" name="radioBtn" id="rdBtn3" /> I want to see which radio button is selected so that I can further process. I am trying this @functions{ var choice = Request.Params["radioBtn"]; } But the "choice" only returns 'on'. How can I know which one of these radio buttons are actually active at this point of time? 回答1: Currently your

how authorization asp(mvc) project from controller?

无人久伴 提交于 2019-12-02 11:33:52
I'm new in asp and I created a login page for my web project but and I set authentication but I can not set authorization for my project! I saw many links like this Authentication and Authorization in ASP.NET Web API but couldn't implementation those on my own project, I don't know where I must to start?! thank you for your help! this is my controller: public class AuthenticationController : Controller { private modelLayOut mLO = new modelLayOut(); public bool existBool = false; // GET: Authentication public ActionResult Index() { return View(); } public ActionResult applicantAuthentication()

project.Models.tableName:The field pvid must be a string or array type with a maximum length of '20'

瘦欲@ 提交于 2019-12-02 11:00:58
I encounter exception error below when i try to add a new entry in the database with : db.patient_visit.Add(pv); db.SaveChanges(); An exception of type 'System.InvalidOperationException' occurred in project.dll but was not handled in user code Additional information: project.Models.tableName:The field pvid must be a string or array type with a maximum length of '20'. Before this, my model is automatically and originally set like below because i did Code-First migration with existing database. [Key] [StringLength(20)] public string pvid { get; set; } Logically, it looks like it is already in

ASP.NET MVC FileResult is corrupting files

泪湿孤枕 提交于 2019-12-02 10:46:26
问题 I've been trying to get my ASP.NET MVC website to export some data as an Excel file. For hours I thought that NPOI was just producing garbage so I switched over to EPPlus. I tested it in LINQPad and it created a proper working XLSX file, so I moved the code over to the MVC app. AGAIN, I get corrupted files. By chance I happened to look at the temp directory and saw that the file created by EPPlus is 3.87KB and works perfectly, but the FileResult is returning a file that's 6.42KB, which is

C# MVC: Multi step form implementation

怎甘沉沦 提交于 2019-12-02 10:27:08
We are building MVC multi-step form that will have 4 steps:- Contact-details, Car-details, Car-images, Car-condition. At each step, we ask few car related details from the user like this: We have to save each step information to the database and we have made separate MVC controller for each step, for example: [HttpGet] [Route("contact-details/")] public ActionResult ContactDetails() { return View("~/Views/ContactDetails.cshtml"); } [HttpPost] [Route("contact-details/")] public ActionResult ContactDetails(ListingDetails listingDetails) { if (ModelState.IsValid) //extract ContactDetails from

Cannot implicitly convert type system linq IQueryable to system collections generic List

混江龙づ霸主 提交于 2019-12-02 09:57:20
Unable to fetch Data from View Model Controller to View,i have properly checked the working of query in LINQpad. However I am missing the conversion of the output of query which can be displayable in View. I have three Data Models Products,Images,Specifications which i combined into ViewModel with only selected properties and want to displaythe same. public class ViewModelController : Controller { private OMSEntities db = new OMSEntities(); // GET: ViewModel public ActionResult Index() { var product = new Product(); var prices = new Price(); var orders = new Order();

Enum RadioButtonFor Editor Template set value

回眸只為那壹抹淺笑 提交于 2019-12-02 09:53:36
Based on this question, I implemented a RadioButtonFor Editor Template. I works great but currently you cannot pass the value you want selected. EnumRadioButtonList.cshtml (Editor Template): @model Enum @foreach (var value in Enum.GetValues(Model.GetType())) { if ((int)value > 0) { @Html.RadioButtonFor(m => m, (int)value) @Html.Label(value.ToString()) } } I call it from View with: @Html.EditorFor(m => m.QuestionResponse, "EnumRadioButtonList") How do I pass the value QuestionResponse (enum) so that the radio button is selected? You can create a custom html helper which will give 2-way binding