asp.net-mvc

Using ELMAH with ASP.NET MVC in VB: Compiling: Elmah does not have a strong name

I've read through the posts and code for passing ASP.NET MVC HandleError errors to ELMAH and converted the code to VB: Imports System Imports System.Web Imports System.Web.Mvc Imports Elmah Public Class HandleErrorAttribute Inherits System.Web.Mvc.HandleErrorAttribute Public Overrides Sub OnException(ByVal context As ExceptionC...

Constructor Dependency Injection in a ASP.NET MVC Controller

Consider: public class HomeController : Controller { private IDependency iDependency; public HomeController(IDependency iDependency) { this.iDependency = iDependency; } } And the fact that Controllers in ASP.NET MVC must have one empty default constructor(*) is there any way other than defining an empty (and usel...

How to get the value of datafieldtext or selectedtext of the selectlist in asp.net mvc?

No javascript\AJAX is to be used. ...

How do I find the absolute path of a controller action?

I need to generate a link to an action and send the link by email. I'd like to call something like this: public string GetAbsolutePath(string actionName, string controllerName, string id) { // Somehow generate the absolute path } I think I can use VirtualPathUtility.ToAbsolute(string virtualPath) but I'm not sure how to get the vi...

Sharing ASP.NET MVC applications

Hi, Like everybody else on this planet, I am currently working on a blogging engine using ASP.NET MVC . I am planning to make this open source under GPL, with a requirement that people already have ASP.NET 3.5 already installed on their machines. Let us say that they do not already have ASP.NET MVC installed (on a shared host) But, I...

How to add CSS class atttribute for Html helper methods in asp.net mvc (VB.NET)?

Name: <%= Html.TextBox("txtName", "20", new { @class = "hello" }) %> I want that in VB.NET , is it .cssclass="hello" or is it something else? ...

MultiSelectList problem

hello I have a problem to get the values and text of the MultiSelectList to work. It gets rendered as: <select id="UsergroupID" multiple="multiple" name="UsergroupID"><option>BookingSystem.Data.Models.Usergroup</option><option>BookingSystem.Data.Models.Usergroup</option><option>BookingSystem.Data.Models.Usergroup</option></select> An...

How should I track changes on any object in asp.net mvc (nhibernate)?

I am looking for a good way to track down every change that is made on an object. We are building a custom framework and we need to have a history (kind of) about who changed which object when and maybe also what. What is a good practice in this case? Extend the save / update methods to write a "log"? Should I try with log4net or kin...

Getting MultiSelectList to select items

Hello I have created a MultiSelectList like this: MultiSelectList UsergroupID = new MultiSelectList(_ug.GetUsergroups(), "UsergroupID", "UsergroupName", u.Usergroups); problem is the getting the list from u.Usergroups (that is EntitySet) to make the items selected. Do I need to cast "u.Usergroups" to something in order for it to sel...

Alternative to reloading model data

I have a controller view which lists recent comments. I also have a textbox and button to add a new comment. When I post to the Save action, I need to validate the textbox. However if the validation fails, when returning to the view, I also need to reload all the comments all over again, which feels like an unnecessary db call. Example...

Do I still need to download something to use DataAnnotation with MVC 2.0 Preview 1?

ScottGu says .NET MVC 2.0 has built in DataAnnotation support, I think that means I don't need to download the DataAnnotation DLLs separately, but when I installed MVC 2.0 and try to use System.ComponentModel.DataAnnotations, my VWD prompts an error message: ...

Create ExtJS components dynamically with ASP.NET MVC

I'm in early phase of building a RIA with ExtJS and ASP.NET MVC. Users in the system will have numerous different user rights that restrict which elements are visible and what actions user can make. For example in the user managment section, only superuser should be able to promote user to 'admin' status. So the 'add admin status' -b...

How to do long-polling AJAX requests in ASP.NET MVC?

Does anyone know how to code up long-polling AJAX requests (for server PUSH notifications) in ASP.NET MVC? Whenever I do it, it seems that only the last browser to open up a window gets the notifications. As if IIS/ASP.NET were canceling the last request because it was hung or something. ...

ASP.net MVC: Where in my design should I create/declare entity keys?

When creating a new entity object that has a foreign key value I need to create a new Entity key (Entity Framework in .net 3.5) for the object, but I'm having trouble deciding where in my application I should do this. Right now when I create a new record with a foreign key, I create the entity key in the controller (in this case a user ...

For someone with experience using xVal, is it worth it to learn and use castle validators over the built in data annotations?

What does the castle validators offer me over standard data annotations? I am a first-time user of xVal, data annotations and castle validators so there will be a learning curve regardless of which I decide. Is it worth it to just start using casle validators (I'm assuming they will be more robust) ...

Logging all yellow screen of deaths, even when its a compilation problem

Earlier today we experienced a YSOD on one of our MVC sites running on IIS on Windows Server 2003. Usually, these are reported via e-mail using ELMAH (using this setup), but since this was a compilation issue (of some sort), it did not get reported via e-mail. The specific error was: "The directory 'App_GlobalResources' is not a...

Passing page for routelink

Hello I have a problem with getting my pager-function to work. For some reason it doesnt like when I try to pass the current pageindex +1 to the same page for it to display next one. <% if (Model.Users.HasNextPage) { %> <%= Html.RouteLink(">>>", "Users", new { page = (Model.Users.PageIndex +1) })%> <% } %> If I only use: ”>...

[ASP.NET MVC] Who's responsibility is it to encode a string?

Hi, Who's responsibility is it to encode a string, the model or the view? I've a string from a database, it's come from the user - I want to keep as a much information as possible in the database, so I'm saving the input verbatim. When I come to display the string, should I be encoding it when I populate the view model, or should the ...

EntityFramework .net 4 Update entity with a simple method

I was looking at this SO question: http://stackoverflow.com/questions/1168215/ado-net-entity-framework-update-only-certian-properties-on-a-detached-entity. This was a big help for me. I know now that I need to attach an entity before making my changes to it. But how can do I do this: I have an MVC website, a Customer Update Page with fi...

Enforce Action Filter on all Controller Actions (C# / ASP.NET MVC)

Hello, I made a new action filter (attribute, similar to [Authorize]) which authorizes access to a controller action based on a session value. However, I'm basically decorating all my controller actions with that attribute (with the exception of very few). So, I thought it would be better to have that Action Filter always executed exc...