asp.net-mvc

asp.net mvc routing question

the default routing works fine mysite.com/home/about and i even see how to customize it to make it shorter so i can say: mysite.com/edit/1 instead of mysite.com/home/edit/1 but how can i make it longer to handle url like the following mysite.com/admin/user/1 // works mysite.com/admin/user/details // does not work mysite.com/admin...

How can I validate a ViewModel in jQuery Dialog?

My AddressEditViewModel has a bunch of attributes marked [Required(ErrorMessage="My Error Message Here")] and/or [DisplayName("etc")]. The DisplayName attributes work: <%: Html.LabelFor(model => model.Field) %> , and I think the Required attributes are working too, but I don't know how to provide feedback on the form (jQuery UI Dialog...

Why is IIS 7 showing me a default 403 page?

I have setup an asp.net 4.0 site where if someone tries to access an authorized area they get redirected to a SignIn page and the status is set to 403. On my local machine it redirects to the SignIn page with the 403 status. On IIS 7 I get a nasty 403 Forbidden page instead of the SignIn page. How can I get it to work on IIS 7 like it...

ASP.NET MVC and navigation

I'm trying to learn ASP.NET MVC, and I want to have menus highlighted on the item that is currently selected. I know I did this before in web forms (although I don't actually remember how at the moment, but somehow with the sitemap). But how can this be done in MVC? It seems like such a basic thing it should be simple to do in MVC? Sur...

LINQ to SQL Finding objects not listed in another list

I am programming a data entry application for a vet and I've followed many of the principles used in the MVC Nerd Diner application. I'm 90% finished with my app, but trying to clean up an annoying issue: Currently when a user adds a pet to an invoice, I have a dropdown that lists all the customers current pets - whether or not they ar...

replacement for try catch(MyEx ex) in each action

I need something that would work like this: public ActionResult Ac() { try { //stuff... } catch(MyException ex) { //handle } } but without putting try catch in each action method ...

ASP.NET-MVC2: Why does TryUpdateModel ignore properties after the second level of the object model tree?

Perhaps I'm missing something here, but it seems that anything in the object model tree 3 or more levels down, is ignored when using TryUpdateModel. For example (simplified): public virtual ActionResult SomeAction(int id, FormCollection form) { IValueProvider vpFrom = form.ToValueProvider(); /* At this stag...

How to store ASP.NET masterpage data in application cache for set duration

Hi, I've been reading 'ASP.NET-MVC Tutorials' to learn how to generate data for the 'masterpage' view in an ASP.NET MVC application. It suggests the pattern of using a 'base-controller' and generating the data in its constructor. My issue is that I wish to store the application data in the application cache rather than the viewdata ...

ASP.NET MVC strongly typed helpers generate wrong input nam when are used inside foreach

Hi guys, I've got a problem with ASP.NET mvc stongly typed helpers. Here is example of wrong behavior: <% foreach (var item in Model) { %> <%: Html.TextboxFor(m => item.Name) %> <% } %> will generate following inputs: <input name="item.Name"..... As you see generated name is wrong, because of wrong algorithm of extracting proper...

ASP.Net MVC Authentication

Hi, I'm aware this has been asked a million times, but all I could find is either very simple scenarios or over-complicated ones that aren't of much use to me (like the huge MembershipProvider sample implementation at MSDN). Here's my problem : I have a database with a Users table. A User has a username, password and some other importa...

asp.net mvc generic controller

I am thinking of implementing a generic Controller in ASP.NET MVC. PlatformObjectController<T> where T is a (generated) platform object. Is this possible? Is there experience / documentation? One related question for example is how the resulting URLs are. ...

How to create Custom Data Annotation Validators

Wanting to create custom data annotation validation. Are there any useful guides / samples on how to create them? Firstly: StringLength with minimum and maximum length. I'm aware .NET 4 can do this, but want to do the same in .NET 3.5, if possible being able to define minimum length only (at least x chars), maximum length only (up to x ...

How to insert distinct value in <select list item>

Hi, I have written a query to get result from table. var queryres = (from r in objTestEntities.module_where r.PID ==id select r).ToList(); try { for (int j = 0; j < queryres.Count; j++) { string sModuleName = queryres[j].Title; int iModuleId = queryres[j].ModuleID; string sVersion = queryres[j].VersionNo; sModuleNameList.Add(new Selec...

Nhibernate/MVC: Dealing with lazy loaded collections in View

I'm currently using an attribute based approach to nhibernate session management, which means that the session is open for the duration of the Action method, but is closed once control is passed to the View. This seems like good practice to me, however I'm running in to problems with lazy loaded collections. (This is complicated by th...

Using WF 4 as navigation framework for ASP.NET MVC2-based wizards

Has any one done that ? I'm planning to use a state machine workflow from WF 4.0 as the navigation framework ... The idea is as follows 1. States correspond to pages. Grouping some states into composite states for anonimous/authorised requests 2. A custom controller factory intercepts the requests, extracts the controller/action nam...

create space between legends and chart area

In mvc charting As I searched there is property called Margin by which we can create space between legends and Chart area , how do I set margin by code . ...

Should controllers in MVC web applications be unit-testable?

It seems to me that web developers of different programming languages often share different opinions on this. For example, Ruby web developers (with Rails being the dominant framework) appear to think of controllers as glue code, which should have functional tests, but not unit tests. A similar attitude dominates in the PHP world, yet th...

Auto-Logout with multiple tabs open

Hi, we've implemented a system similar to the one described in this other SO post. Basically, if the user doesn't do anything for 14 minutes, we prompt them that they will be logged out. If they click on "keep me logged in" we do an ajax request to keep their session alive, otherwise, they are redirected to the logout page after a minute...

Asp.net mvc ajax site.master

I want to use a different model for site.master. Instead of of the old "<"asp :Content PlaceHolder ID="SideContent" runat="server" "/ >" tags I want to use ajax to dynamically display my aspx pages(within Site.master). so no complete reload unless explicitly asked for. I also want to do this with very little change to the way my projec...

Question about ASP.NET MVC routing

Hello I have actions SomethingEditor, SomethingDelete, SomethingSave, SomethingAdd and i want set these routing: site/Something/Editor, site/Something/Delete, site/Something/Save etc How i can do it? ...