mvc

Fetching data within an ASP.NET MVC ViewModel class?

For those that create ViewModels (for use by typed views) in ASP.NET MVC, do you prefer to fetch the data from a service/repository from within the ViewModel, or the controller classes? For example, we started by having ViewModels essentially being DTOs and allowing our Controllers to fetch the data (grossly oversimplified example assum...

Disable Session state per-request in ASP.Net MVC

Hi, I am creating an ActionResult in ASP.Net MVC to serve images. With Session state enabled, IIS will only handle one request at a time from the same user. (This is true not just in MVC.) Therefore, on a page with multiple images calling back to this Action, only one image request can be handled at a time. It's synchronous. I'd like ...

Redirect to previous view and inject a javascript alert

Hi all, I need to do the following: I have a textbox, which appears in every page of the site, that allows to subscribe to a newsletter. This I've done already and the user is redirected to previous view after subscription. I'd like to add a javascript alert to the page the user is returned to, something like "Thanks for subscribing"....

Redirect to getter if the set value of the data property does not meet the condition

Hi Guys, I want to default value(getter value) to be set for the data property , if the value set by the user does not meet the condition(without private variables). Here is the code public class TreeViewModel { public a() { this.Height = 200; } public int Height { get; set ; } } If the user sets the value of height less...

asp.net mvc session state.. help?!

Hi all, Has anyone ever eperienced session's being shared application wide? My MVC application has the vanilla setup but for some reason, my sessions are being shared. I didn't really think about it when I could switch between FF and IE and maintain a logged in state but now, I've noticed that I can switch machines too. My web.confi...

How to enforce URI segments to Kohana pagination after the page URI segment?

I'm using Kohana's pagination library and it lets you specify the parameter uri_segment at initialization. When it generates the pages links, they will have that uri_segment you specified, and after that, the page link. Let's say: /some/uri/segments/6 where 6 is the page. Now, that enforces the page number to be the last uri segment. W...

JQGrid in MVC app Add form error on submit click

Hi - I am trying to use the JQGrid plugin and have run into an issue I can't seem to get around. First I'm using the latest version on the grid (3.5.3) in an ASP.NET MVC app. Almost everything is working great - loads my data, edit form fires the correct Controller method. My issue is with the Add record Form. The form displays fine but ...

ado.net entity framework massive confusion

Hi All, I really hope you can help me as I am about to just throw my MVC/Entity Framework project in the bin and start a MVC/Linq project. I am building a forum as a project just to get to know MVC/Entity, and I have 4 tables which are all related. Forum_Category, Forum, Topic, Reply so there is a 1 to many on Category_ID between F...

MVC How to keep a model skinny

After watching this video, I am wondering if I am using my controllers wrong. What exactly should a controller contain? For my blog, I have a post controller which has methods: create show list loadPost like dislike Whereas my post model only has a few access rules, validation rules and relation information. Are there any examples of a...

ASP.NET MVC cannot scaffold with types from a referenced assembly

I am building my very first MVC project and I would like to use scaffold a new view using custom types that exist in a referenced assembly. Is scaffolding only available for locally declared types? I add a new view via the "Add View" dialog, I choose to "Create a strongly-typed view" and I pick my class type in the "View data class" d...

Can I serve images in ASP.NET MVC application from Views directory

I have some pages designed by someone else as simple HTML that I need to dump into my MVC application. Not surprisingly the images are stored in a local /images directory. I'd like to be able to serve the images up from the Views directory where the main view pages are. I'd rather do this than make it its own virtual directory, but I...

Html.ActionLink construct wrong link when a non-mvc route is added

Hi there, I have an application here with a mix of webform and mvc. I specify the routing as below routes.Add("AspxRoute", new Route("Upload/New", new WebFormRouteHandler<Page>("~/Uploads.aspx"))); routes.MapRoute( "Default", // Route name "{controlle...

How do I get the referrer URL in an ASP.NET MVC action?

How do I get the referrer URL in an ASP.NET MVC action? I am trying to redirect back to the page before you called an action. ...

WinForms, WPF, Silverlight, Asp .NET, MVC, ... What to choose?

I've been programming for over 15 years and started with .NET 5 years ago. We built our framework for windows data-oriented apps and it is a quite stable. At this point, we are considering to make a new platform. But, I am a little bit confused with all these new technologies. We considered CAB and SmartClient technologies but there are...

What is the best MVC, Doctrine2, Datamapper practice?

I am looking into using Doctrine2 with my Zend Framework setup. I really like the datamapper pattern, mainly because it seperates my domain models with my database. My question is what is the best practice for using Doctrine and DQL with my controllers? controllers uses Doctrine DQL/EntityManager directly for saving/loading my domain ...

Correctly reference jQuery in ASP.NET MVC

Encountered such problem: Ive created a new blank project of ASP.NET MVC site. Then Im trying to add a reference to jquery-1.3.2.js from Masterpage head. But in this case, page doesnt loading to browser. Ive bee trying and src="<%=Url.Content ("~/Scripts/jquery-1.3.2.js") %>", all the same. Then I moved the script reference to the end o...

Who is responsible for initializing a model from remote sources

I know that I am for responsible for this in the code, but in a object-oriented and MVC sense, who should really load the model. I have a model for representing RSS feeds that is being loaded from a url. The model is really thin and the controller manages downloading and parsing of the XML and then passes it on to the model. Is it better...

ASP.NET MVC ViewPage Lifecycle

I would like to know when (which event/function) the class System.Web.Mvc.ViewPage runs when it reads the @Page directive of the view. In particular, I would like to programmaticly interpret the values of the @Page directive, override them, then have the cycle continue. ...

Concept of, Framework for , How to Test View of MVC (Ruby on Rails)

I am now doing the UI from fresh so I want to make it fully test. Could anyone suggest the correct way to do this and where should be the good place to start? such as Concept, Framework. (I already know some concept of testing) ...

Can anyone tell me if and why I should void using ViewData in ASP.Net MVC?

Hi Guys This has probably come before and is probably very subjective. I have been tols to avoid using ViewData and use a FromViewModel class to pass informaiton to the view istead. Are there any major advantages of this approach? Thanks Davy ...