asp.net-mvc

Script & CSS Registration Helper in ASP.NET MVC?

I have tried to use ASP.NET MVC for a while, then I face a problem that I don't want to include all of my js and css in master page. But how can I register it in head of master page from my specific view? ...

New asp.net charting controls - will they work with MVC (eventually)?

Scott Gu just posted about a new set of charting controls being distributed by the .NET team. They look incredible: http://weblogs.asp.net/scottgu/archive/2008/11/24/new-asp-net-charting-control-lt-asp-chart-runat-quot-server-quot-gt.aspx The million dollar question is ... will they work with MVC, and if so, when? ...

How to load a page with gravatar and jquery?

I am using gravatar to load avatars for each user that posts a story on a page. I also am using jquery to round the corners of some span elements on the page. Unfortunately, it looks like grabbing the avatars from gravatar occurs before the jquery effects are applied (Without the gravatar code the elements are immediately rounded) so the...

ASP.NET MVC, JSON & non JavaScript clients

I need to ensure that an application I am developing is accessable and also works with JavaScript turned off. I just need a pointer to assist with the following. I had 3 'chained' select boxes and I wanted JavaScript enabled clients to have a nice Ajax experience. I can easily write the required functionality to populate the chained box...

Html.ActionLink doesn’t render # properly

When using Html.ActionLink passing a string containing the # char renders it like it is but if you UrlEncode it renders as %2523. I believe it's a bug. MVC Beta Release. Is it really a bug? http://example.com/test# is rendered as http://examplee.com/test%2523 instead of http://examplee.com/test%2523 ...

How to post an array of complex objects with JSON, JQuery to ASP.NET MVC Controller

My current code looks like this, how can I pass my array to the controller and what kind of parameters must my controller action accept? function getplaceholders() { var placeholders = $('.ui-sortable'); var result = new Array(); placeholders.each(function() { var ph = $(this).attr('id'); var sections = $(thi...

Scriptmanager Asp.Net Mvc

I'd like to have some of the scriptmanager features in the new Asp.net MVC model 1- Script combining 2- Resolving different paths for external javascipt files 3- Minify and Gzip Compression Here is what I found but not sure is the best way for mvc approach. In general what is the your approach to deal with javascript code in the MVC...

ASP.NET MVC validation and views

I'm using MVC to validate some html text boxes on a page, for example in my controller there is if (String.IsNullOrEmpty(name)) { ModelState.AddModelError("name", "You must specify a name."); } if (ViewData.ModelState.IsValid) { return RedirectToAction("Index"); }...

ASP-MVC Forms authentication - cookie not persisting

Hi I have my own linq to sql database with a nice login method which gives me back a user. I have followed the 101 examples there on the web as to how to add the cookie to the client. FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, _u.id.ToString(), Dat...

ASP.NET MVC Beta 1 - URI Routing Syntax

I have scoured the web for a decent explanation of the routing syntax in ASP.NET MVC Beta 1 but I still can't get it to work. Please could someone explain what I need to put in my Global.asax.cs file to have two supported URIs for my site: www.mysite.com/map.aspx (i.e the site without any explicit parameters/actions for performing the...

Unit Testing: Creating a 'mock' request to simulate a MVC page request

Hi, How do I go about creating a mock request for my asp.net-mvc application for unit-testing? What options do I have? I am using FormsCollection in my Actions so I can simulate form input data also. ...

Whats the best way to set a dropdown to selected in ASP.NET MVC markup?

I have this html... <select id="View" name="View"> <option value="1">With issue covers</option> <option value="0">No issue covers</option> </select> It won't let me insert code like this... <select id="View" name="View"> <option value="1" <% ..logic code..%> >With issue covers</option> <option value="0" <% ..logic code.....

ASP.NET MVC Folder Controller Html.ActionLink

I have the following code in my Site.Master page of an almost empty ASP.NET MVC Project. <li> <%= Html.ActionLink("Home", "Index", "Home")%> </li> <li> <%= Html.ActionLink("Feed List", "FeedList", "Home")%> </li> <li> <%= Html.ActionLink("Monitored Feeds", "MonitoredFeeds", "Home")%> </li> <li> <%= Html.ActionLink("Abo...

linq, mvc and partial class

I have dbml with single table users i want add partial class for User and add another property like so: public partial class User { public string FullName { get { return FirstName + " " + LastName; } } } and then use in my View something like: <%...

IIS 6.0 wildcard mapping benchmarks?

I'm quickly falling in love with ASP.NET MVC beta, and one of the things I've decided I won't sacrifice in deploying to my IIS 6 hosting environment is the extensionless URL. Therefore, I'm weighing the consideration of adding a wildcard mapping, but everything I read suggests a potential performance hit when using this method. However, ...

File path as MVC route argument.

Part of my application maps resources stored in a number of locations onto web URLs like this: http://servername/files/path/to/my/resource/ The resources location is modelled after file paths and as a result there can be an unlimited level of nesting. Is it possible to construct an MVC route that matches this so that I get the path in...

ASP.NET MVC OutputCache doesn't work for root URI

I'm learning ASP.NET MVC and bugged by one issue. In the HomeController, the Index action has OutputCache attribute, but it seems doesn't work. [HandleError] public class HomeController : Controller { [OutputCache(Duration=5, VaryByParam="none")] public ActionResult Index() { ViewData["Title"] = "Home Page" + DateTi...

ASP MVC Routing with > 1 parameter

I have the following route defined routes.MapRoute( "ItemName", "{controller}/{action}/{projectName}/{name}", new { controller = "Home", action = "Index", name = "", projectName = "" } ); This route actually works, so if I type in the browser /Milestone/Edit/Co-Driver/Featur...

Regular expression to match a string (1+ characters) that does NOT end in .ext

I need to test a url that it does not end with .asp So test, test.html and test.aspx should match, but test.asp should not match. Normally you'd test if the url does end with .asp and negate the fact that it matched using the NOT operator in code: if(!regex.IsMatch(url)) { // Do something } In that case the regular expression would ...

How to use Autofac in a 3 layered web application (ASP.NET MVC)?

The examples I can find use a two layer architecture, where the controllers directly use the repository classes in the data access layer. See here or here. Where would you register components from the data access layer if you have a service or business logic layer that uses those components? The data access layer should ideally not be r...