asp.net-mvc

ASP.NET MVC Routing: Can I have an action name with a slash in it?

What I want to do is have a page at /Products/Details/{id} which routes to the action details on ProductsController, and then an edit version of the page at /Products/Details/Edit/{id}. I tried to do this using [ActionName("Details/Edit")] on the Action but that doesnt work. ...

How do I extend Html.ValidationMessage so that I can include an image as the error?

I would like to reduce the following code. The below code works, however it is not very tidy etc. <label for="Name">Name:</label><%= Html.TextBox("Name")%><% if (!string.IsNullOrEmpty(Html.ValidationMessage("Name"))) { string Error = HtmlRemoval.StripTags(Html.ValidationMessage("Name")); %> <img src="Error.gif" alt...

How to select table rows in ASP.NET MVC

Hi all, I'm struggling to figure out the correct way to do something in MVC which wouldn't be difficult in WebForms, and I'm hoping someone will be able to point me in the right direction. Basically, I am displaying a table of data and the user should be able to select zero or more rows. When they press submit I want my controller to ...

Debugging in Visual Studio 2008 without setting an break point

I have downloaded an open source project that I would like to use to further my ASP.NET MVC skills. The project is split up into multiple smaller projects. When I launch the web site in debugging mode, is there a way to set the debugger to stop without having set a break point so I can step through the code and see what is happening bef...

Checkboxes in ASP.net MVC (c#)

I'm creating a checkbox list to handle some preferences as follows... <ul> <%foreach (var item in ViewData["preferences"] as IEnumerable<MvcA.webservice.SearchablePreference>) { var feature = new StringBuilder(); feature.Append("<li>"); feature.Appen...

Using Telerik Webforms Controls with ASP.NET MVC

I have been searching the web for a concrete and simple example of binding a Telerik RadComboBox with a DataSet by following the ASP.NET MVC pattern, but couldn't find out a working snippet. This DataSet is present in a Class situated in the Model folder of my project. Can anybody help me on this ? ...

What is the best way to validate date and time.

In my asp.net mvc program, the user will input the date in one field and the time in another field. The time will be in 24hr mode so the user can enter 00:00 - 23:59, and the date should be in the typical mm/dd/yyyy. With all the different options available for validating the input, such as javascript/jquery/masked input on the client s...

Changing the Ajax.Form target depending of the success or the fail

Hi, On a view, i have a partial view rendering an ajax form that allows me to create a new element. On the same view, i have a partial control that list the elements already in the database. My create action will redirect the the list action if everything is ok or to the create action with an error message if something is wrong with t...

All inbuilt ActionResults in ASP.NET MVC

I'm looking for a list of the inbuilt (and 3rd party would be a bonus) ActionResults you have available to you in a controller in ASP.NET MVC. So far I've discovered the following: ContentResult - this.Content() ActionResult - this.View() JsonResult - this.Json() JavascriptResult - this.Javascript() PartialViewResult - this.PartialVi...

How to get Windows user name when identity impersonate="true" in asp.net?

I'm creating an intranet asp.net mvc application that everyone in the company should have access to. I need to run the website impersonated for database access etc., but I want to know who each user is. When I look at Page.User.Identity.Name it's blank. Is it possible to get the user's windows account name even though the site is runn...

Maintain a user's session state in an ASP.NET MVC app hosted on a web farm

What is the best way to maintain a user's session state in an ASP.NET MVC app hosted on a web farm? Out application currently uses the standard ASP.NET session on IIS 6.0 but we want to move the app to a web farm environment. I have read that we can use SQL Server session state for our application but I just want to know if anybody was...

Mapping empty values to null using ASP.NET MVC v2 Preview 1

I have a POCO class for an edit model class PersonEditModel { public string ScreenName{get;set;} } It's common for ScreenName to be null when my domain model is converted into this PersonEditModel. When I present this in MVC 2 form using the html helpers I get back an empty string (if the user didn't add anything into screenname), ...

Asp.net MVC and normal html pages

Hi! I'm about to create quite simple website which will contain several static pages (they will never change) and one dynamic change (let's call it news). I'was wondering whether it's possible to use MVC here without having to create controllers and views for these "static" pages. Isn't that just too much overhead? Is there a way to mak...

MVC Membership Kit Question

I have my site up and running just fine using the kit. My question is, when you click on the check box to stay logged in, is their a way to extend the amount of time that you stay logged in for. My client would like something like an hour. ...

jQuery AJAX see redirect as status 200 not 302?

I am using jQuery and the jQuery.form plugin to submit my form (also using ASP.Net MVC). Problem is the user is in a section of the site that uses forms authentication and if their auth cookie expires during their time on the page instead of getting back a status of 302, which would be the redirect to the login page, I still get 200? ...

xVal - Generates Rules Only For The ID Field

I am following this post. Server side validations work as expected. But the clientside validators are only getting generated for the ID field. My Linq2Sql Entity Class has two properties ID & CategoryName and below is my Metadata class [MetadataType(typeof(BookCategoryMetadata))] public partial class BookCategory{} public class BookC...

Alternative To Sessions? (asp.net mvc c#)

I'm being told that the server we're being given to use has 2gb of ram but is nearly maxed out with the current main application that runs on it. But for the site were building, which is wholly reliant on a web service, we need to pass the response to the previous request within a chain... i.e. Page One var stepone = project.webservic...

Ado .net data services in the same app

I have an application with an EDMX and an Ado .net data service in it. I would like to make a call from the same application (not an http call) to the ado .net data service and would like to use the url like syntax to query using a string of filters that have been built up programatically: public class AdventureWorksService : DataServic...

ASP.NET MVC - Find Absolute Path to the App_Data folder from Controller

What is the correct way to find the absolute path to the App_Data folder from a Controller in an ASP.NET MVC project? I'd like to be able to temporarily work with an .xml file and I don't want to hardcode the path. This does not work: [HandleError] public class HomeController : Controller { public ActionResult Index() { ...

asp.net mvc javascript postback

I'm mixing asp.net webforms and asp.net mvc. To use webforms I've included routes.IgnoreRoute("Reports/{*pathInfo}"); in the public static void RegisterRoutes(RouteCollection routes) method. It seems to work just fine. But javascript postbacks on the asp.net webform pages don't work. Specifically <script type="text/javascript"> fun...