asp.net-mvc

Which layer should construct a View Model?

Hi Guys, I'm using the S#arp architecture, and I can't remember where I read it, but they say they ViewModels should be stored at the service layer, and your views should submit the viewmodel to the service for processing. My question then is this. Which layer should construct the ViewModel? Should it be at the service layer, and the ...

Is passing a Command object/Reader to a function a good idea?

I've been getting some inexplicable errors (running out of connections from the connection pool) with MySql database with .Net 4 (C#). Till now all my attempts at finding a reason for this have been in vain. Now I also have a situation in which a lock on a table is not cleared for a long time even though all I have been doing is read ope...

How to update model in the database, from asp.net MVC2, using Entity Framework?

Hello. I'm building ASP.NET MVC2 application, and using Entity Framework as ORM. I am having troubles updating object in the database. Every time I try entity.SaveChanges(), EF inserts new line in the table, regardless of do I want update, or insert to be done. I tried attaching (like in this next example) object to entity, but then I g...

ASP MVC: Custom Validation Attribute

I'm trying to write my own Custom Validation attribute but i'm having some problems. The attribute i'm trying to write is that when a user logs in, the password will be compared against the confirmation password. namespace Data.Attributes { public class ComparePassword : ValidationAttribute { public string PasswordToCompareWith { g...

How Can We get the Values of the Form without Post in asp.net MVC?

I Have Make a Create Form. & I want the Values in Controller how can I get them Without Postback the Whole Page? Any article please help ...

ASP.NET client side validation with dataannotations - javascript minimumlength zero

Hi! I'm doing client side validation on a project I'm working on. Everything works, except for the minimumlength property of the StringLength attribute (it works when submitting and a serverside validation is done): [StringLength(50, MinimumLength = 6)] The javascript generated by Html.EnableClientValication(); is the following: // ...

modal popup example mvc

I want to have a modal popup that may also have validation upon post. Can I have an example please. ...

ASP.NET MVC - Views location Problem : The view 'Index' or its master was not found

Hi all, I've create an asp.net MVC 2 project, it works fine!! I've been asked to integrate the project in an existing web project in classic asp.net (I've add the folder containing the source, and not make a new project, because they have to bee in same project) I've configured my web.config file <pages pageBaseType="System.Web.UI.P...

AccountModel into a Repository and Interface

I'm trying to separate the default AccountModel in mvc2 into a separate interface and repository. I've created an Interface and Repository and copied over the code from the AccountModel. I can register users and create accounts but in Visual Studio I'm getting the error below on the AccountController (* below). Error 1 Inconsistent ac...

Do I need to sign my assemblies for an asp.net mvc app?

If I'm deploying an asp.net mvc app, do I need to sign my DLLs? They won't be placed in the GAC. ...

Sending an array of complex objects in the get string in C# ASP.NET MVC

Hi, I want to send an array of objects in the get request string. I know this isn't the optimal solution, but I really just want to get this up and running. If I have a class, something like this public class Data { public int a { get; set; } public int b { get; set; } } public class RequestViewData { public IList<Data> MyDa...

"Security aware" action link?

How can I create a "security aware" action link that detects if a user is authorized to click (invoke) the action? Hide link if user is not allowed to use that action... Depending from web.config (authorization) and [Authorize] attributes on actions PS I guess it is bad practice to mix those 2 in MVC? ...

ASP.NET Dates Deployment Issue

Hi guys, I recently bought some webspace with dailyrazor.com. I have deployed an application I have been working on to the server and am currently trying to workout the bugs but I can't seem to solve this one. I have set up my database in Visual Studio to use the one I have create with dailyrazor the same db the deployed version will u...

Does anyone know why jquery dialog is showing stale content on ajax update ?

I have a series of links and when i click on a link i want to show a dialog with detail information. This detail is returned from an jquery ajax request. I am using the following code below to show a partial result through ajax onto a jquery dialog. Here is the jquery code: $(document).ready(function() { $('a.click').live('click', ...

AJAX Toolkit for ASp.net MVC

Is there any ajax toolkit for asp.net MVC ...

How to redirect by throwing an exceptions from an Asp.NET controller?

My controllers all extend a basic UserAwareController class, that exposes GetCurrentUser() method. I would like any call to this method to redirect to the login page if the user is not already logged in. Can I accomplish this by throwing some exception from this method? How can I cause a redirect to happen when this exception is thrown?...

How would you pass objects with MVC and jQuery AJAX?

I am finally experimenting and trying to learn MVC after years of asp.net. I am used to using asp.net AJAX PageMethods where you can pass an object that automagically gets parsed to whatever type the parameter is in that method. Javascript: PageMethods.AddPerson({First:"John",Last:"Doe"}); Code-Behind: [WebMethod] public static Resu...

Asp.net MVC Ajax form that return Json to a javascript method.

Hello guys, I have an ajax form that saves a object in the database then return a Message like this: return Json(new {Message = "Message!"}, JsonRequestBehavior.AllowGet); We are ok here, but I don't know HOW I'll get this result in the view to display in a jQuery modal. My ajax form is like the following a...

Why isn't uploadify and asp.net mvc 2 playing nice for me?

First of all, I've checked out all the SO threads, and googled my brains out. I must be missing something obvious. I'd really appreciate some help! This is what I've got. UploadController.cs using System.Web; using System.Web.Mvc; namespace NIMDocs.Controllers { public class UploadController : Controller { public Acti...

MVC validator errors disappear by the time control is given to the controller

I have a simple model FilesModel for updating a string Description and the boolean value of a checkbox Archived for a few (already uploaded) files, and FilesModel has a validator FilesModelValidator that gets run when this data is posted. This validator does nothing more than check that each file has a description. I know that it runs an...