Questions tagged [asp.net-mvc-5]

1

votes
1

answer
600

Views

Automapper with Column Order Data Annotation

I am having an issue on application start up when I setup my AutoMapper config. It is throwing an exception when creating the mapping for a business object to a data object. The issue appears to be coming from the use of data annotations. It is worth mentioning that the mapping from data object to b...
Jonathan Nixon
1

votes
2

answer
1.3k

Views

LINQ to Entities does not recognize the method 'Int16 Parse(System.String)' [duplicate]

This question already has an answer here: LINQ to Entities does not recognize the method 'Int32 Int32(System.String)' method, and this method cannot be translated into a store expression 4 answers I tried to find what causes the issue LINQ to Entities does not recognize the method 'Int16 Parse(Sys...
Sleepy
1

votes
6

answer
5.7k

Views

Unable to retrieve metadata for models when adding a controller

I'm learning ASP.NET MVC 5 on 'Visual Studio 2015 Community' as a newbie. I'm trying to add a controller with Entity Framework models. And an error appears. I'm so confused. Here is my code: using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Com...
Luan Tran
1

votes
1

answer
4k

Views

How to configure authentication & Authorization in Mvc 5

I'm developing a website which includes a log-in to customers and sellers ,so the users & sellers can log-in and maintain their profiles. I created the Mvc project by selecting 'No authentication'.But now i need to add authentication to my project.I followed the database first approach to create the...
Thilina De Silva
0

votes
0

answer
5

Views

How to Apply BundleConfig.cs on specific views(I don not want to apply BundleConfig.cs on Specific View)

As you know that bundles files are applied on every view as we described it in layout page so i want to that on specific view bundleconfig.cd file would be apply and i cannot find a solution to do that kindly if u help me?
MSB
0

votes
0

answer
5

Views

signalR - web socket connectionData: [] after connection start in ASP.Net MVC

My current application has an online voting process this was previously build feature using signalR older version - 1.1.4 & that online feature working perfectly in older version but later we did some .net version upgrade and we decide to upgrade signalR too. so we upgraded it to 2.0.3 to do this I...
TDM
1

votes
3

answer
811

Views

Disable CheckBox Dynamically using JQuery

I have a collection of checkboxes within a form. I am looping through the collection to check and/or disable the checkboxes. The checking works fine; however, I am having an issue with checking if the checkbox is disabled or not. It always return false even when the checkbox is enabled. I looked at...
Jean B
1

votes
2

answer
35

Views

Misspelled or missing module?

I have an ASP.NET MVC5 app in which I am using AngularJS. In this, I have a module called atTheMS with a factory for a service called albumService and 3 controllers: ListController, EditController, and DetailsController. The service and controllers are all dependent on the atTheMS module, yet I get...
jacksonSD
1

votes
2

answer
1.8k

Views

How to store an Image URL in database and use it in ASP.NET MVC?

I'm creating an application for uploading images to the databse and showing them in a gallery. I would like the image linking to a page. I just have no idea how I can call the url from the model in the view. Or should I make a special controller function here ? ImageGallary.cs public partial class...
Swolschblauw
1

votes
2

answer
131

Views

MVC5 Partial Views

I have looked through the examples on here, but I don't fully understand Views and Partial Views completely in MVC. I have a view called 'Edit.cshtml' with the following code: @Html.LabelFor(model => model.AddressLine1, htmlAttributes: new { @class = 'control-label col-md-2' }) @Html.EditorFor(model...
theguitarman
1

votes
1

answer
273

Views

Why does Ignite UI Hierarchical Grid throw a NullReferenceException when I add a layout?

Whenever I load the grid without adding a layout the parent grid loads just fine. However, whenever I add the layout, A NullReferenceException is thrown when binding data to the parent. public ActionResult Index() { GridModel grid = GridLoadOnDemandModel(); grid.ID = 'Services'; grid.LoadOnDemand =...
kyle
1

votes
3

answer
83

Views

Avoiding string literals when using ModelState.AddModelError

In my MVC 5 app when I want to return validation error for the form values I use this pattern in the Controller: ModelState.AddModelError('PropertyName', 'Validation Message'); Is there a recommended practice that does not use string literal in the Controller for property name? I am using .Net 4.5 a...
lng
1

votes
2

answer
3k

Views

ASP.NET Identity 3.0 - how is the database with user tables created in an MVC application?

I am trying to build a simple login system from the ground up, using the code-first approach with ASP.NET MVC v5, Entity Framework v7, and Identity v3. I'm modeling my app after the ASP.NET MVC app with individual user logins template that Visual Studio comes with. All I want is for the user to crea...
jmk22
1

votes
2

answer
791

Views

How fix Compiler Error Message: CS1061 in Asp.net MVC?

I'm using ASP.net MVC 5 with Razor Engine. I want to create a page to register users . I create a Model and MetaData model for my User entity . All my codes are here . I think everything is Ok but I got this compile error : Compiler Error Message: CS1061: 'NP1.ViewModels.RegisterVM' does not contain...
shima amini
1

votes
1

answer
262

Views

How to implement a many to many relationship in ASP.NET using SQL Server

Basically I am trying to insert a userId value and a RoleId value in an intermediate table in SQL Server 2010. The problem is that the code is not reaching the table and it stays empty while, using breakpoints, I can see the values to allocate the role are correct. I am using ASP.NET MVC 5 as a scho...
Student
1

votes
1

answer
318

Views

MVC5 : How do I specify form-control to limit the number of decimal places?

I have following decimal field: [DisplayFormat(DataFormatString = '{0:n2}', ApplyFormatInEditMode = true)] public decimal MyDecimal { get; set; } In my Razor view Price @Html.EditorFor(model => model.MyDecimal, new { htmlAttributes = new { @class = 'form-control decimal-small inline' } }) @Html.Vali...
Danny
1

votes
2

answer
1.3k

Views

How to get Knockout to read value from hidden input

I have a form with a hidden input in my MVC application whose value I want read by Knockout. Unfortunately the observable function in Knockout REPLACES the original value in the DOM with whatever value is specified within the parenthesis so that self.title = ko.observable() changes the value of th...
Keith Harris
1

votes
4

answer
139

Views

Add strings to the list of string

I am trying to fill a list of strings but it throws null reference exception. Code: public class Validation { public List Errors { get; set; } } Class where all validation errors are to be stored: public object Post(Currency currency) { ClientData clientData = new ClientData(); if (ModelState.IsVal...
Uzair Ashraf
1

votes
4

answer
633

Views

Rendering web files without routing + layout.cshtml

I want to start a new AngularJS single page application in ASP.NET 5 (Visual Studio 2015). I will only be using ASP.NET for its WebAPI functionality and not for view rendering (Razor). Therefore I'd prefer it if I didnt have to have a HomeController and _Layout.cshtml from which to bootstrap my Ang...
Chris
1

votes
2

answer
218

Views

Why if statement always returns false in asp.net mvc when updating data?

I used this code to update user's data in asp.net mvc 5 I think every thing is OK , but I don't know why I'm getting error message and data didn't saved and if (ModelState.IsValid) in Controller is false always . Could anyone help me please ? Admin Controller [HttpGet] public ActionResult EditUser...
shima amini
1

votes
1

answer
82

Views

ASP.NET MVC page with multiple forms and classes of a model [closed]

I have a page in ASP.NET dedicated to role management. Administrators can add users to a role, create new roles, edit their respective names and delete them. In the page, I need to call @ModelType AdminModel.AddRole, @ModelType IEnumerable(Of Microsoft.AspNet.Identity.EntityFramework.IdentityRole),...
devSparkle
1

votes
2

answer
99

Views

Custom XML feed based on .Net MVC model

We're redoing a legacy application using .Net MVC 5. Part of the application generates an XML feed which other applications use. We've built a model called Call [XmlRoot('record')] public class Call { [XmlIgnore] public int ID { get; set; } [XmlIgnore] public string CustomerInitials { get; set; } [X...
dspencer
1

votes
1

answer
50

Views

EF6 write once to DB with FK relation

I am wondering if it is possible to write once to the database on two objects where one object has a FK to the other. For example lets say the DB structure is: C1 public class Team { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id {get; set;} } public class Player { [DatabaseGe...
Bojan
1

votes
1

answer
121

Views

what is the purpose of the returnURL that some developers pass to Actions methods?

i have seem some developers when they develop Login(), logout() actions put two parameters to the methods, first one is the login model and second a string returnURL. But i can login and logout a user without having the second paramter (returnURL) because i just need remove the authentication cookie...
Phill Greggan
1

votes
1

answer
694

Views

Visual Studio 2015 / MVC 5: Attach to Process: Cannot obtain value of the local variable

I can connect to the w3p process on my IIS box just fine. I can step through, although it seems to skip some areas. Also, when I try to view a variable value, I get: Cannot obtain value of the local variable or argument because it is not available at this instruction pointer, possibly because it has...
Beau D'Amore
1

votes
1

answer
506

Views

Is it possible to compile a ASP.NET MVC 5 project with a mac

Hello everyone so first and foremost I am thinking of creating an I-phone app and those could only be created in a mac laptop which runs Xcode. I currently have Visual Studio's in my windows laptop and have a project there (Api that makes database calls to postgres) if I get a mac will this same pro...
Ignacio Perez
1

votes
1

answer
67

Views

Detect if a section is available before @RenderSection [duplicate]

This question already has an answer here: How can I know if a non-required RenderSection exists? 1 answer I have a piece of code which I would like to render conditionally, if a section exists... Navigation @RenderSection('navigation', false) But I only want it to render if the section exists on th...
series0ne
1

votes
1

answer
557

Views

MVC Razor - Assigning an id to a button

This is my ActionLink razor button: @Html.ActionLink('Delete Partial', 'DeletePartialView', new { id = item.ClubID }, new { @class = 'btn btn-danger btn-xs' }) How would I assign it an id of deleteClub-opener so that when it is clicked it calls this jQuery code: $('#deleteClub-opener').click(functi...
Cathal O 'Donnell
1

votes
1

answer
1k

Views

How to trap a WS-Federation callback in an OWIN MVC5 app to automatically create an identity in local database?

I am currently working on a vb.net MVC5 application and using WS-Federation to authenticate all the users from an ADSF 3.0 server. Everything is working fine; when the users try to access a secured controller marked with the AUTHORIZE attribute, the users are redirected to the STS login page, they...
Patrice Bechard
1

votes
1

answer
109

Views

Is it possible to use @html.EditorFor template that would in tern use another editorfor with ViewData.ModelMetadata

I'm trying to EditorFor template to display an Infragistic's control like so. View CallManagement.cshtml @Html.EditorFor(model => model.ConfirmationDaysOutToPerform, 'Spinbox') Template Spinbox.cshtml @Html.Infragistics().NumericEditorFor(m => ViewData.ModelMetadata).ButtonType(TextEditorButtonType....
kyle
1

votes
1

answer
891

Views

asp.net mvc5 ajax post returns 404 after switching to IIS 7.5 from IIS Express

I'm making an MVC5 app on Visual Studio 2012. I wrote up an AJAX call and got it to work just fine, then I switched its web server to IIS 7.5 from the previously set IIS Express, now I get 404's on the AJAX calls when I run it. (everything works fine if I switch back to IIS Express) is there somethi...
Kevin
1

votes
1

answer
472

Views

asp net mvc change model within if condition

I know we can only have one model in a view. But I want to get it within a condition. @if (ViewBag.type == 'multiple') { @model IEnumerable } else if (ViewBag.type == 'single') { @model Student } But It gives me error. ' Only one 'model' statement is allowed in a file.' Thanks for help.
oneNiceFriend
1

votes
3

answer
2.4k

Views

asp.net mvc 5 - Passing a ViewBag item back to the controller

I am trying to pass a ViewBag item from my view back into the post method for that view but I am having difficulty. This is a simplified version of my methods: public ActionResult CreateGame(int id) { var selPlayer = db.Players.Find(id); if (selPlayer == null) { return HttpNotFound(); } ViewBag.SelP...
CianGallagher
1

votes
1

answer
2.6k

Views

Posting Json object to an external API from asp.net mvc action method

I want to integrate with a 3rd party Rest API. Now the API have the following definition for a Create operation:- > URL :- https://:7272/restapi/json/v1/resources?AUTHTOKEN > HTTP METHOD: POST > > Sample Requests > > curl -X POST -k -H 'Content-Type: text/json' > 'https://IP:7272/restapi/json/v1...
John John
1

votes
1

answer
1k

Views

attempting to access glimpse.axd and getting error

i've installed glimpse through console package manager by this Install-Package Glimpse.EF6 Glimpse.EF6/1.6.5 is installed on system and added in preferences. following 'http://getglimpse.com/Docs/' tutorial, when i try to access http://mylocalhost/Glimpse.axd it shows me error 'HTTP Error 404.0 - No...
Muhammad Omer
1

votes
2

answer
3.3k

Views

How to Get the Value of a List Type Property using propertyInfo

private static void Getproperties(Object Model) { Type objType = Model.GetType(); PropertyInfo[] properties = objType.GetProperties(); foreach (PropertyInfo property in properties) { object propValue; //Checking if property is indexed if(property.GetIndexParameters().Length ==0) pro...
Nitin Bourai
1

votes
1

answer
397

Views

Multiple Column returns undefined in MVC using MCAutocomplete Jquery UI

my multiple column in mvc returns undefined. what do i missed? or there is wrong with my code? pls help. Controller public ActionResult EmployeeIDSearch(string term) { // Get Tags from database using (var ctx = new DASH_FAEntities()) { var tags = (from e in ctx.EmployeeMasters where e.EMT_EmployeeID...
qwerzxcxyz
1

votes
1

answer
1.4k

Views

ASP.NET MVC 5 dynamic controller routes

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-...
Stephen
1

votes
2

answer
733

Views

Nested Layouts MVC5

I am new to MVC so pardon if my questions come across as stupid. I have a main layout file (_MainLayout.cshtml) and a secondary layout file (_AdminLayout.cshtml). Both these files reside in my /Views/Shared folder. The _MainLayout.cshtml looks like: U - @ViewData['Title'] @Html.ActionLink('Admin', '...
Rico Strydom
1

votes
2

answer
1.1k

Views

ASP.NET MVC FileResult is corrupting files

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 corrupte...
Gup3rSuR4c

View additional questions