asp.net-mvc

Custom DataAnnotations Validator Derived from RegularExpressionAttribute

The Gu provides an example of how you might create a custom validator that overrides RegularExpressionAttribute (http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx). The advantage of this is that you don't have to create a custom Model Validator (http://haacked.com/archive/2009/11/19/aspnetmvc2-custom-...

how to get an collection of ids int[] in post action (selected checkboxes)

I need to get in an action method the values from the selected checkboxes on a form how would you do that ? (or probably get them all and see who was selected) public ActionResult (int[] ids) ... <input type="checkbox" value = "1" /> <input type="checkbox" value = "2" /> <input type="checkbox" value = "3" /> <input type="checkbox" v...

LINQ to SQL for tables across databases. Or View?

I have a Message table and a User table. Both are in separate databases. There is a userID in the Message table that is used to join to the User table to find things like userName. How can I create this in LINQ to SQL? I can't seem to do a cross database join. Should I create a View in the database and use that instead? Will that work?...

how can i get the Model from an ViewResult in a asp.net mvc unittest?

Hi, i call a controller action in a unit test. ViewResult result = c.Index(null,null) as ViewResult; I cast the result to a ViewResult, because that is what i'm returning in the controller: return View(model); But how can i access this model variable in my unit test? ...

Problems with Partial Views in ASP.NET MVC 2

this is the master page : <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head runat="server"> <title><asp:ContentPlaceHolder ID="TitleContent" runa...

Does MVC replace traditional manually created BLL?

I'm used to creating the UI, BLL, DAL by hand (some times I've used LINQ-to-SQL or SubSonic for the DAL). I've done several small projects using MVC since its release. On these projects I've still continued to write a BLL and DAL by hand and then incorporate those into the MVC's models/controllers. I'm looking to optimize my time on pr...

How can I get controller type and action info from a url or from route data?

How can I get the controller action (method) and controller type that will be called, given the System.Web.Routing.RouteData? My scenario is this - I want to be able to do perform certain actions (or not) in the OnActionExecuting method for an action. However, I will often want to know not the current action, but the "root" action bein...

site.master problem

How open pages in Main Content Place Holder? I am using ASP.NET MVC2. ...

Entity Framework Update Error in ASP.NET Mvc with related entity

I have run into a problem which have searched and tried everything i can to find a solution but to no avail. I am using the same repository and context throughout the process I have a booking entity and a userExtension Entity Below is my image i then get my form collection back from my page and create a new booking public ActionRe...

Regex match numerical range

I am trying to write a simple regex to match a percentage value range 1%-100% Is there a better way to write this? ^([1-9]|[1-9][0-9]|100)%$ ...

ASP MVC: Keeping track of logged in users.

I'm creating a ASP MVC application. And because of the complex authorization i'm trying to build my own login system. (So i'm not using asp membership providers, and related classes). Now i'm able to create new accounts in the database with hashed passwords. But how do i keep track that a user is logged in. Is generating a long random...

Setting up a routing scheme in ASP.NET MVC, need some advice.

Hi, I'm trying to build up a proper routing scheme for my products section in MVC 2. I've got the following criteria: Links of the format /Products/(MX[0-9]+) and /Products/(BDL[0-9A-Z_]) Need to route to ProductsController.Show(Id = $1) Links of the format /Products/([a-zA-Z0-9/]+) Example: http://www.mysite.com/Products/Cameras/D...

Top 5 reasons for using ASP.NET MVC 2 rather than ASP.NET MVC 1

I've been using ASP.NET MVC 1 for a while now, and am keen to take advantage of the improvements in MVC 2. Things like validation seem greatly improved, and strongly-typed HTML helper methods look great. So, for those of you who have real-world practical experience of using ASP.NET MVC 1 and are now using MVC 2, what are your top 5 rea...

Stored Procedure call with parameters in ASP.NET MVC

I have a working controller for another stored procedure in the database, but I am trying to test another. When I request the URL; http://host.com/Map?minLat=0&amp;maxLat=50&amp;minLng=0&amp;maxLng=50 I get the following error message, which is understandable but I can't seem to find out why it occurs; Procedure or function...

IHttpModule not being applied to virtual directory

I have a network folder that is mapped to my iis app as a virtual directory and I'm trying to do some authentication for files that are located there with an ihttpmodule. I've verified that the ihttpmodule is firing properly for anything else in my app, just not the files located in virtual directory. Most of what I've found is that th...

IIS not serving up .dat files.

Hi all, I have a ASP MVC web application that uses a plugin to load images and points for a 3d application. When debugging with the the Visual Studio development server the images and the points are served up great... http://i148.photobucket.com/albums/s19/littleniv/Debugging/local.png Second image: same url but iis.png When running...

Integrating ASP.NET MVC 2 with classic ASP

I'm in the process of moving a large classic ASP application to ASP.NET MVC 2. Questions: My question is about project organization. I would prefer to not mix the MVC code with the ASP code in the same VS project. I'd like to have an MVC WAP with areas that match the parts of the website that I'm migrating. For instance, the old site ...

Passing data from a View to a controller in ASP.Net MVC

Hello, I have a dictionary I'm passing to a View. I want to be able to pass the values of that dictionary back to a Controller action from this same View. Is there anyway this can be accomplished without using a form? The situation is that I need to be able to pass these back to a controller action that is called when a user clicks an...

Two parameters in asp.net mvc route

Hi. This is a modification to a question I've asked before on this forum. My controller action: public ActionResult SearchResults(string searchTerm, int page)... My view: <%= Html.PageLinks((int)ViewData["CurrentPage"], (int)ViewData["TotalPages"], i => Url.Action("SearchResults", new { page = i }))%>... The route entries: routes...

Is there an event in Asp.Net MVC that gets triggered whenever a view is finished processing/rendering?

I want to tie in to MVC to trigger some code to run whenever the View is finished processing but not yet finished sending data to the browser. ...