asp.net-mvc

IEnumerable<T> VS IList<T> VS IQueryable<T>

New to the MVC.net scene (and .net for that matter), but seems I find a wide array of options when wanting to populate a "list" with data. In my case at the moment, I'd like to populate a list from a select query of items and render the results in JSON for output, so bear with me.... So, my viewmodel class is something like : [Seria...

ActionFilter or RenderAction in ASP.NET MVC?

I'm working on an ASP.NET MVC controller with several action methods, all of which need the same bit of data. This data requires a lookup that can only be done with the route values (so, I can't do the lookup in the constructor). I'm sure this has been discussed at length, but I've yet to find a satisfactory recommendation. What's t...

When is document.ready fired when the script is loaded through the RederAction method?

I have an action that summarizes an entity's information. The view for the action contains a script to handle the summary's UI. I also have another action that loads this view multiple times (to summarize multiple entity instances). It seems that the jQuery document.ready function fires each time the action's view is loaded on the page. ...

ASP MVC, Django or Rails?

I've to start my master thesis project and I've to choose a technology to work with. I've used Rails and ASP MVC, in two projects, but never used Django, only some play with it. But I've some experience with python and really like the admin interface. The objective of my master thesis is a creation of portal to a public hospital. I hav...

Thread.CurrentPrincipal claims incorrectly to be anynomous

I'm seeing requests on my server that appear to be made by an anynomous client, although I'm certain they were made by an authenticated user - I have fiddler logs showing that the client sent valid asp.net auth cookies, and server logs indicating that the cookie arrived and is valid. The problem has been observed across all browsers. T...

How to display an ASP.net MVC project version in page?

In WinForms, I'd use Application.ProductVersion. I've tried using System.Reflection.Assembly in various ways but can never get the version of just the MVC project. ...

MVC Window.Open

Basicaly I want a button that opens a page in a new window containing my http://fake.com/Report/PageFixes... page. Currently I have a button in a form but if there is a better way to do it then I'm up for that too. <% using (Html.BeginForm("PageFixes", "Report", new { id = 9 }, FormMethod.Get, new { onSubmit="window.open()" })) %> <% {...

Add slashes in Area name on an ASP.NET MVC 2 route

Currently I have an Area in my ASP.NET MVC 2 project call 'API', which is self explanatory. As the API of my web application matures, I will soon need to add version numbers to my address. ie/ Instead of : http://site/API/ I will need http://site/API/1.0/ http://site/API/1.1/ ... What's the best practise to achieve this in ASP.NE...

MVC Partial Login Control

Hi All, All im trying to do is create a login control that i want to place within my home page. Ive created a Login User Control as follows: <%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of MyWebsite.LogOnModel)" %> <% Using Html.BeginForm() %> <%: Html.ValidationSummary(True, "Login was unsuccessful. Please co...

MVC 2.0 Routes, redirect request, ignore request

IIS 7.5 MVC 2.0 ASP.NET 4.0 If my MVC site getting external request for any not existed files, e.g SomePage.aspx is there any ways to redirect such request to any controller/action. I am using elmah and it is throwing errors when such kind of requests coming. Also i did add routes.IgnoreRoute("SomePage.aspx") in global.asax.cs to ign...

Is WordPress any good (from a .NET developer perspective)?

I've been looking for a good ASP.NET MVC blog engine (I believe many others have too). I'm keen not to use the standard ASP.NET blog engines as I want to keep away from viewstate. There isn't really much out there to hang one's hat on in the MS space, and in the back of my mind I keep thikning I should be looking outside of the Microsof...

Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider'

I am converting an ASP.NET MVC application to ASP.NET MVC 2, and I get the following error: Cannot apply indexing with [] to an expression of type 'System.Web.Mvc.IValueProvider' Here is the code: public static void AddRuleViolation(this ModelStateDictionary modelState, RuleViolation error, ...

DataAnnotations dynamically attaching attributes

Apparently it is possible to dynamically attach DataAnnotation attributes to object properties at runtime and as such achieve dynamic validation. Can someone provide code sample on this? ...

Pros and Cons of using ASP.NET MVC with Entity Framework?

What are some pros and cons of using ASP.NET MVC with Entity Framework in .NET 4.0? Any 'gotchas' in live scenarios? ...

how to access property in usercontrol.ascx from usercontrol.ascx.cs

Hello all, I want create for paging a usercontrol. How can I access properties in usercontrol.ascx from usercontrol.ascx.cs? Property in usercontrol.ascx.cs: /// <summary> /// gets actual page index /// </summary> public int PageIndex { get { return _pageIndex; ...

ASP.Net MVC: Entity Selection in View without using dropdownlist

I have an EditTask View for editing the following properties for a Task that I am modeling. [Task Name] [Project Name] [Assigned Employee] Task Name and Project Name are just simple text boxes. I want Assigned Employee to be a selection from all the available Employee's currently in the database. Dropdownlist is not ...

Obtain View name in Controller, ASP.NET MVC.

Hi, I am using asp.net mvc. I have 4 pages that show list of events(different type of events) and "Details" link on each page leads to "EventDescription.aspx" View. The "EventDescription.aspx" has a link called "Back to Events" which has to take the user to the appropriate page. Eg: if the "Details" request came from page1 the "Back t...

ASP.NET MVC 2 Problem with custom ModelValidator

I am trying to validate that either of 2 textbox fields in my view have a value supplied. I made this Model Validator: public class RequireEitherValidator : ModelValidator { private readonly string compareProperty; private readonly string errorMessage; public RequireEitherValidator(ModelMetadata metadata, ControllerCont...

Linq to SQL replacing related entity

I have a Client entity and PostCode entity in Linq to SQL model. The Clients table in database contains client_postcode column which is a FK column to postalcode column in PostCode table, which is a varchar column primary key for PostCode table. When updating Client, in my code I do this // postcode updating.PostCode =...

ActionResult with optional routevalues affecting other actionlinks on view

I have an actionresult that looks like: public ActionResult MyFriends(Guid? friendId) { if (friendId != null){ return View(...); { else{ return View(...); } } If the friendId is supplied, I return a certain model that my view knows how to react to. Otherwise, if no friendId is given, the view r...