asp.net-mvc

Casting problems when trying to be generic / 'type free' | ASP MVC

Question Is there a way to define a method only once in C# (in a helper class or something) not knowing which type is given to be returned? Long explanation I get the following error: Unable to cast object of type System.Data.Objects.ObjectQuery1[WerkStageNu.Vacancies]' to type 'System.Linq.IQueryable1[WerkStageNu.Models.IFil...

How can I prevent the user from navigating back to a previous page?

I have an ASP.NET MVC application, with three views: view1, view2, view3. The logic way for the user to navigate through these is: view1 -> view2 -> view3. When the user reaches view3, then I must prevent them from loading view2, even by using the "Back" button in their browser. What is a good, browser-independent means of implementing...

Entity Framework - Update entity with child properties.

I have an entity that has one child and I need to update it, but, in the TryUpdateModel method, it does not accept an strong typed object (accepts only a FormCollection), and when I try to update it, I get the following error. {"A relationship is being added or deleted from an AssociationSet 'FK__SG_Usuari__ID_Si__534D60F1'. With cardi...

How do I pass a Dictionary as a parameter to an ActionResult method from jQuery/Ajax?

I'm using jQuery to make an Ajax call using an Http Post in ASP.NET MVC. I would like to be able to pass a Dictionary of values. The closest thing I could think of was to pass in a multi-dimensional array of strings, but the result that actually gets passed to the ActionResult method is a single dimensional string array containing a str...

setting page html title from within an action

Hi, How can I set the Html title from within a controllers action? ...

Master Page Name in OnActionExecuting

In an attribute inheriting from ActionFilterAttribute is there a way I can get to the current master page name OnActionExecuting? Thanks, Nath ...

Is Mono stable and fast enough?

C# looks great because it is a compiled language which seems to run quite well without too much CPU and does not consume too much memory. And StackOverflow and ServerFault are good examples of an MVC/.Net/C# stack that scales. C# is also interesting because despite being compiled, it still has a lot of advanced features as a language on...

ASP.NET MVC and Entity Framework: query persistance

Hi, I'm facing the following problem: in the controller I select the data I need and store it into the ViewData; using (Models.SkedruleEntities ctx = new Models.SkedruleEntities()) { ViewData["users"] = (from u in ctx.User select u); } In the View I try to read from the ViewData like this: <p> <%foreach(User user in (IEnumera...

Using ASP.NET MVC with generic views

Hello all I am currently investigating MVC for a new project we are starting. So far I like it, but I'm wondering about something. The actual views that we will be displaying will not be known at design time, we will be specifying in a config file somewhere how to build these views. Is this pattern supported by MVC or do we need to kno...

MVC - Model binding with multiple entities on the same page

I am wondering how to use Model Binding in a scenario where I am returning information from more than one entity on a page? I want to display a combination of fields from two separate entities, ie Customer + Address. I am using Microsoft's DAAB and custom business entities for my model. Any ideas? ...

MVC - Insert data into multiple entities from same page

I have a single page which collects related data into a series of input fields. When the user clicks submit I want to insert the data into two different database tables in one go. ie I want to get the primary key from the first insert, and then use it for the second insert operation. I am hoping to do this all in one go, but I am not s...

asp.net MVC, how to redirect registered users that don't have a profile to page?

We are building a site using asp.net mvc. We want to allow the user to easily register and create an account. There is though a very special piece of information, that will be registered in his profile, that we want to show to him *after registration is finished, and he is logging in for the first time. The logic is whatever the URL tha...

What kind of a performance cost is there with IOC (asp.net mvc)?

Hi, When using a IOC library like ninja, is there a performance cost to this or is it a one-time hit during application_start mostly? ...

Shaml with NHibernate Contrib

Shaml looks awesome for project kick-start. Would be great if it could be configured to also include NHibernate Search and other Contrib projects. Any plans for this? ...

How to create picture link in ASP.NET MVC?

Well, how to create picture link like this up or down votes (on the left) from link below? (ajax enabled link) <%= Ajax.ActionLink("Vote!", "AddPictureVote", "Vote", new {id = Model.PictureId}, new AjaxOptions{UpdateTargetId = "addvote"})%> ...

Should I verify an email address when a user registers on my website?

I have a membership site in beta right now... At the moment, when a user registers, it marks the account as unverified and sends them an email with a link to verify their account. The real reason for doing this is to make sure they entered their valid email address correctly. So I was contemplating on removing the verification step to ...

Can I override a Controller ActionAttribute?

I have a BaseController which has an attribute on it rather than individual actions therefore all controllers run through it. I have one action on a controller that I do not want the attribute code to run on. How can I implement this? [MyAttribute] public class BaseController : Controller { } public class WebPageController : BaseCont...

Recording ASP.NET MVC performance metrics

We want to time how long certain actions run for in an ASP.NET MVC application. We're using ActionFilters to start and stop a timer each time a contoller action is invoked. The result is a small dataset a bit like this: { ContollerName: 'Account', ActionName: 'Index', ExecutionDuration: 287, TimeRecorded: '2009-07-02 17:34:...

How to convert this asp.net MVC code from c# to vb.net

Hi everyone! I need a quick hand figuring out what this code is doing, and how to make it work in vb.net <%=Html.PageLinks((int(ViewData["CurrentPage"], (int)ViewData["Totalpages"], x=> Url.Action("List", new {page = x})) %> i've figured out most of it. but the x=>Url.Action("List", new {page = x}) part is throwing me off. I trie...

Custom Routing Rules (e.g. www.app.com/project/35/search/89/edit/89)

I would like to create routing rules like the following: www.app.com/project/35/search/89/edit/48 ---> action is edit in the project controller The passed variables should be project# (35), search# (89), and edit#(48) Can someone help me structure a routes.MapRout() for this. I want to use: routes.MapRoute( "Default", ...