Questions tagged [asp.net-mvc-3]

14377 questions
1

votes
1

answer
990

Views

Getting entities of a certain type using entity frameworks return error - LINQ to Entities does not recognize the method 'System.Type GetType()'

I am trying to filter out entities of a certain type. I am using Entity Framework, and I have a parent entity, and various children that inherit from the parent entity. I am trying to filter out one of these children. For example, I have the following structure: Address : Entity PostCode : Address...
Karan
1

votes
3

answer
8.7k

Views

MVC client side error message not showing

I want to implement client side validation on my form, but none of the error message is showing when I put the wrong data. Below is my model code: Model: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace Layou...
user3762810
1

votes
2

answer
7.2k

Views

Knockout.js Select value binding to object

I am failing with Knockout select list binding when using an object as a select list value. It works fine if I use a string, but I want to bind objects. I have a Gift object and it has a Title, Price and Company. I have a select list of companies and each company has an Id and Name. The initial sele...
TheGwa
1

votes
3

answer
1.3k

Views

ASP.NET MVC JSON Entity Framework - Saving data

I have an asp.net MVC3 application, trying to save data to MS SQL table (Entity Framework). Here is the table: public class CasesProgress { public virtual long ID { get; set; } public virtual long Learner_ID { get; set; } public virtual long Course_ID { get; set; } public virtual long StudyCase_ID {...
hncl
1

votes
1

answer
3.9k

Views

MVC & ASP.Net Web Form : Viewstate?

I have used ASP.Net Webforms. I am currently learning MVC, and I have read that ASP.NET MVC–generated pages don’t contain any View State data. Can someone explain what is the substitute for viewstate in MVC? How come they eliminated viewstate? As controls also have viewstate, what's the alternat...
Constant Learner
1

votes
1

answer
1.4k

Views

Validating certain parts of input string using Fluent Validation

I am using ASP.NET 4 and Fluent Validation. I am trying to setup a rule that checks if my user name starts with "adm". I have the following, giving me errors. I tried to follow the online sample but it is not working: RuleFor(x => x.UserName) .NotNull() .WithMessage("Required") .Must(x => x.UserNam...
Brendan Vogt
1

votes
1

answer
431

Views

DateTime formatting error in the MVC view

I am developing MVC app. I am trying to format the date in view. In one statement it working fine , but in another statement showing the error. Below statement work fine. @Model.CreatedDate.ToString("dd-MMM hh:mm tt") This statement generates an error. @Model.ModifiedDate.ToString("dd-MMM hh:mm t...
bnil
1

votes
3

answer
2.4k

Views

View returns NULL to controller Action (Model not binding)

I've been struggeling with this one for quite a while. Everything goes as planned until I try to return the values filled in from the View back to the Controller (See below): Using Fiddler, as soon as I submit the data it shows valid html (Please see below:) To my understanding, this should bind to...
fransHbrink
1

votes
1

answer
2.3k

Views

MVC async without waiting on task to complete

I make an ajax request to invoke a controller action like so: Controller: [AsyncTimeout(8000, Order = 3)] [HandleError(ExceptionType = typeof(TimeoutException), Order = 4, View = "TimeoutError")] public async Task RemovePackageAsync(CancellationToken cancellationToken, string packageId, ICollection...
ShaneKm
1

votes
1

answer
138

Views

Caching partials based on logged in user

I have an MVC application with approx 20 controllers. In this application I want to cache certain views (mostly partials) for 60 seconds, i.e. the result would only change once per minute, even if the underlying data changed during that minute. Seems simple enough. The complication is that the part...
KingCronus
1

votes
1

answer
2.3k

Views

Using ASP.NET Server Controls in MVC?

On my current project I need to add a functionality that allows the user to view a thumbnail of their uploaded PDF. I've found a handy component that achieves this (the basic version is free, but it's enough for my current needs). Anyways, the control is pretty outdated (2010), therefore there does...
Mohammad Sepahvand
1

votes
1

answer
863

Views

How to fake an HttpContext and its HttpRequest to inject them in a service constructor

In a console application, I would like to use a service that would normally need the current http context to be passed to its constructor. I am using Ninject, and I think I can simply fake an http context and define the proper binding, but I have been struggling with this for a few hours without suc...
1

votes
2

answer
733

Views

MVC / Repository Pattern - Architecture

I have a project in which I am using NHibernate and ASP.Net MVC. The application is intended to allow users to track certain data and then produce views of statistics based upon the data entered. The structure of my application thus far looks something like this: NHibernate Layer: Contains Repositor...
Ant P
1

votes
1

answer
427

Views

MVC3 View with multiple models

I have a model for a view. This view contains a an @Html.DropDownList whose values are in a model. How can I have my view take both model for different parts of the program? For example, I have @model IEnumerable @{ ViewBag.Title = "my title" } @Html.DropDownList(m =>m.name), new set(Model.list, "va...
jpo
1

votes
2

answer
1.3k

Views

When to use MVVM (i.e. Knockout.js) or simply return an EditorTemplate object from Controller action

In cases where new items need to be added to a list via ajax, what is the biggest benefit of using something like Knockout. So far what I have been doing is, on my view, use an editortemplate (with asscociated viewmodels) to render a list of items. Then to add a new item, I make a request to an acti...
getit
1

votes
4

answer
379

Views

Pass hidden ID when textbox is changed

I have multiple textboxes, every textbox has a related hidden field, the hidden field's ID is a concatenation of a string with the model's ID (ex: "FormState25") How can I pass the ID of a hidden field when a textbox being changed? I'm using the following code to detect textbox change: $("#body-cont...
SVI
1

votes
1

answer
4.4k

Views

How do you display values from a table based on another table in MVC 4?

I have 2 Models a customer table and a product table. I am pretty new to MVC and I have created a model and I have the auto generated controller and views for details, delete, create... etc... My models are: [Table("Product")] public class Product { [Key] [DatabaseGeneratedAttribute(DatabaseGenerat...
Pittfall
1

votes
2

answer
825

Views

How to send data from view to controller in MVC3

Hello everyone I would like to ask how to send data from view to controller ? I would like to describe my question with my controller and view as you can see below Here is the login action controller [HttpPost] public ActionResult Login(Panel model, string Username, string Password, string CaptchaVa...
learnmore
1

votes
1

answer
1.7k

Views

HTTP Error 401.0 when debugging ASP MVC project in Visual Studio 2010

I recently took over an ASP MVC project at work, and when trying to debug in Visual Studio 2010 I receive an HTTP Error 401.0. I'm completely new to using ASP MVC, so any help would be greatly appreciated. Thx! Detailed Error Information: Module ManagedPipelineHandler Notification ExecuteRequestHand...
NealR
1

votes
1

answer
4.1k

Views

IIS 8 Server error 500 logs

So we decided to try out the new Windows Server 8 / IIS 8. Running in VS-Dev server I simply catch all server errors in Application_Error() in Global.asx and log these using log4net. Now I have 2 problems, first is the exceptions doesnt seem to be caught in Application_Error() on our deveolpment ser...
taracus
1

votes
2

answer
341

Views

It is possible to view ASP.NET MVC3 sessions in Google Chrome?

Let's assume that we have the following piece of code: Session["username"] = GetUserByCredential(username, password); It is possible to view that session in Google Chrome ? I tried to see in Resources tab but no success.
Snake Eyes
1

votes
2

answer
2.1k

Views

How to modify Authorize attribute to allow a group of User Roles in MVC 3

In my MVC3 wep app, I have extended the Authorize attribute like below public class MyAuthorizeAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { if (Authenticate.IsAuthenticated() && httpContext.User.Identity.IsAuthenticated) { var authCookie = htt...
SKCS Kamal
1

votes
1

answer
1.2k

Views

ASP.NET MVC returns damaged zipped file

I'm trying to download zip file. But downloaded zip file is damaged or corrupted and I can't open it. I use Ionic.Zip library for create my File.zip. My code: public static Stream LoadImages(int[] ids) { var images = new List(); var imgNames = new List(); foreach (var id in ids) { string fName; imag...
user571874
1

votes
1

answer
617

Views

Route MVC area content the same way as controllers and actions?

I've got a MVC 3 project with an area, let's call it MyArea. I'd like to place scripts and styles that are specific to MyArea under that area's subfolder, resulting in a project folder structure like this: /Areas/MyArea /Areas/MyArea/Controllers /Areas/MyArea/Scripts
Kjell Rilbe
1

votes
1

answer
89

Views

is it necessary to handle exceptions shown in the IntelliTrace

today when checking a breakpoint in visual studio 2010 , I saw that several exceptions had been thrown during execution of application . but none of them are related to my code and the application works as it should. is there any way to handle these and is it necessary to handle these exceptions or...
mohsen dorparasti
1

votes
1

answer
1.7k

Views

Date is 01/01/0001 and not the date that is in the database?

I have this line in my sql server 2008 r2 database, but I don't understand: 2012-12-06 11:00:36.703 and is of type DATETIME When I display it in my view it is: Mon, Jan 1, 0001 Here my code: var allNews = ZincService.NewsService.GetNewsPostsForId(id); List newsItems = new List(); foreach (var newsI...
charlie_cat
1

votes
3

answer
330

Views

How to use css to display an avatar pic with details next to it?

i have this part of html in my view: i have my avatar showing with the newsItem.CommentDate and ViewBag.UserName underneath the avatar. How can i get the date and username to display NEXT TO the avatar?? thanks
charlie_cat
1

votes
3

answer
896

Views

MVC3 Razor custom templates for primitive types and downcasting

I've got a view model as: public class AttributeEditorViewModel { public long AttributeId { get; set; } public string DisplayName { get; set; } public object Value { get; set; } } The model is build using a model builder so that a final view model has a list of above objects: public class AttributeL...
1

votes
1

answer
278

Views

MVC3: Grouping Action Filters or calling Action Filters from other action filters

I'm trying to write an attribute class that can be used on all my "admin" actions which then effectively applies all relevant action/auth filters to that action. For instance, I always apply the AuthoriseAttribute and a custom AdminLayoutAttribute, so my intention is to just have an AdminAttribute w...
hofnarwillie
1

votes
1

answer
1.1k

Views

How to set FormsAuthentication in asp.net mvc 3 with Entity Framework mapper?

I'm trying to set authentication username and password manually in web.config file in my mvc 3 app: And the following warning occures: Warning 1 The element 'authentication' has invalid child element 'credentials'. List of possible elements expected: 'forms, passport'. C:\Users\Aleksey\docu...
Aleksei Chepovoi
1

votes
2

answer
2.2k

Views

How to use ActionInvoker.InvokeAction? - ASP.Net

I am new to MVC ASP.NET and needed to call an action from one controller in an action of another controller. There I created object of controller and called my required action as below, controllerOne co = new controllerOne(); co.requiredFunction(); but one of my senior advised me to not use this app...
Premio
1

votes
2

answer
11.1k

Views

how to log out the current user in asp.net mvc

I have used the below link to end a session. http://pure-essence.net/2010/02/14/jquery-session-timeout-countdown/ In that i am able to redirect to the login page. But the user is not logging off. Just it is redirecting to that page. But it is not logging out. How can i log out the session in that c...
Jonathan
1

votes
2

answer
1k

Views

Populate a <select> list from a server side collection upon the user selecting a value in another list

If a user selects a value from an HTML drop down list A, I want to make an ajax call to the server to populate the values in HTML drop down list B based on the user's selection. I am using ASP.NET MVC 4 with EF 4. How do I do that?
Water Cooler v2
1

votes
1

answer
382

Views

Impossible to launch nop.Admin web project with vs 2010

I downloaded nopcommerce v2.65 and i met 2 problems , and i managed to resolve the first. First problem : Unable debugging the project , and the solution is to modify ProjectExtensions section of Nop.Admin.csproj like this : False True 2619 / http://localhost:2451/ False False False Second problem ,...
user1018697
1

votes
1

answer
3.3k

Views

ajax post data null in mvc3 controller method

One of my jquery ajax posts sends post data to my .NET MVC3 controller method, but at the controller method, the data shows up as null. I have many other ajax posts that use practically the same method body, and they all work fine, so I'm not sure what is happening. Ajax post: $.ajax({ url: '/Entit...
keithhamilton
1

votes
1

answer
579

Views

Returning a query string in ActionLink

Hi I am trying to to pass a query string to the link and I have writen it like this: @Html.ActionLink(subcategory,"Index" , "Products" , new { category = subcategory}) The way I written it I recieve this and it seems it does not recognize the actionName: http://localhost:2100/?Length=8 If I remove n...
Nistor Alexandru
1

votes
2

answer
3.5k

Views

Uploadify setting file size limit

I am working on a project i have used uploadify control for file uploading,i have to set file size limit to 5MB, i've seen its documentation Here I tried setting 5MB but still when i am selecting file around 3MB it is showing file size error I also tried setting value without any unit (ie 5120) but...
1

votes
1

answer
1.6k

Views

Include external Razor Helper Function

Is there a way to import a razor in-line helper in the view? I tried the following: Inside PaginationTemplate.cshtml... @helper KnockoutPagination(string id, string context) { Prev Next }
Abe
1

votes
1

answer
1.2k

Views

Changing default directory structure in asp.net mvc

I am working on asp.net mvc project which is quite large in size. I am new to the MVC stuff. As Asp.Net MVC have default folder structure Controller, Views or Model so can we change this structure. what if instead of Controller i have different folder? Is it possible?
Rahul Rajput
1

votes
2

answer
224

Views

Implementing single signon using LDAP in an MVC 3 application?

Using MVC3, EF 4.1 I need to validate the username against LDAP and stored his user info in object that would persist throughout his visit (timeout is not concern). I need this object to check if belongs to a group? Example properties to enable access: isNextGenMonitor, isNextGensupervisor, isNextG...
Chaka

View additional questions