asp.net-mvc

ASP.NET MVC Redirecting to default page/route when content is not found

Let me say I have a route/action for showing content pages like this: /Page/{slug} where {slug} can be anything that a visitor types in but if left empty it defaults to "Default". I have my route definition handle the case where {slug} is empty or Default or anything else, so that is setup fine. Now, what do you do in those cases wh...

jQuery.ui.datepicker with Asp.Net MVC dateFormat mapping

Is there somewhere somebody who did a mapping of the c# dateFormat to the datePicker dateFormat, since I already know the C# dateFormat, I don't want to have to check the datepicker documentation everytime I have to build a custom date Format. for exmple, i want to be able to specify in my helper dateFormat of 'dd/MM/yy'(c#) and it woul...

How do I call a controller method from JQuery?

I have ajax code for asp.net (non-mvc) to call to a webMethod to get additional data from the server for a request. But I can't seem to figure out the url to give my JQuery in MVC. <script type="text/javascript" language="javascript"> function SubmitAjax(url, message, successFunc, errorFunc) { $.ajax({ type:"POST", u...

How do I find out the error count in a ASP.NET MVC View?

I want to format the title of my ValidationSummary using a string something like: "There are {0} errors on this page." How do I find out the number of errors without doing it in the controller and adding it to ViewData? ...

Asp.Net MVC builds slow w/complie views,Need to speed up builds for CI!!

I have setup our project with Team City 5.0 for continuous Integration. It works fine, but I had to change our VS 2008 .csproject file to allow our views to get complied correctly. I have read the following guide. link text. It takes about 3 minutes to build on our desktop and with the CI server! I am looking for a way to speed up our bu...

Need help coming up with a better HtmlHelper Extension method.

Hi all, I've inherited the following code and i was wondering if i could pick at your brains to see if there's a nicer way to do duplicate this. Heres the html for most of our partial input views <% if (Html.IsInputReadOnly()) { %> <td> Id </td> <td> <%= Html.TextBox( "Id" , (Model == null ? null : Model.Id) , new { @read...

Creating a mock URL referrer in ASP.Net MVC for Unit Testing

I'm currently testing my application and am stuck on trying to figure out how to create a custom fake URL referrer. I've tried to hard code it, but am getting an error that it is read-only. Here is what I've tried so far: fakeController.HttpContext.Request.UrlReferrer.AbsolutePath = "http://www.yahoo.com"; as well as, fakeControlle...

ASP.NET MVC 2's Model Validation outside the context of your views

I was reading this blog post on ASP.NET MVC 2's new model validation and found it to be pretty cool. I see the value in keeping things DRY by adding a couple attributes to a class property and then automagically getting client and server side validation (as long as your controller checks for valid models). That said, imagine an ASP.NET...

ASP.NET MVC: When to use custom HTML helper methods vs Html.RenderAction?

It's a little unclear for me on when to use a custom helper method and when to use RenderAction and also when to simply use ViewData instead. Some of their functions overlap slightly. For example, if I were to create a Category navigation bar, would I create a new helper method and place that in some partial view? I had initially though...

Asp.net MVC Wysiwyg EditorTemplate.

I have implemented CKEditor via an EditorTemplate called wysiwyg.ascx Everything loads fine in edit view, when I attempt to save the model back to the database via POST Edit ActionResult in the controller. the property that uses the wysiwyg comes back null. I am not sure how to solve this. ...

ASP.NET MVC use of Application Controlle pattern

Hi, I been building my first ASP.NET MVC application and so far am getting to grips quite well with it I think. Some of the concepts are still fuzzy (routing) but I have an idea. One of the things we do with our WebForms apps is to route navigation through an Application Controller [Fowler] to handle our page navigation based on the cu...

ASP.NET MVC Membership provider

Hi I have an MVC website, and it is running on IIS6. Since i have not access to the webserver, i use the .aspx extension (in global.asax). I have a controller called "Quiz" and all of their methods marked with an authAttribute. When the user is not authorized, it should redirect to "/Account.aspx/Logon?ReturnUrl=Test.aspx", but i get a ...

ASP.NET Membership Provider - Single Login

I'm considering utilizing the ASP.NET Membership Provider for a few different web apps/tools with a single login approach. REQUIREMENTS User logs in to my.domain.com and sees a list of apps/tools that they have permission to use. The user selects the tool they'd like to use and clicks the link. When the tool opens, it is able to i...

asp.net mvc 2 UIHint with multiple defonitions

hi there. im using data annotation with buddy classes for error etc however i have a field for photo on the view it should be an image but on the edit and add it should be a file upload ??? but UIHint will only let me have one, so how do you have multiple UI for one type in your class? thanks ...

Multiple AntiForgeryTokens on a View with a MasterPage

Has anyone had to deal with multiple AntiForgeryTokens on a child view of a master page? The scenario I am thinking about is as follows: The view contains a Form with an AntiForgeryToken rendered as a hidden field. The view is contained by a master page that has another AJAX submitted form. The issue here is that I need to encapsula...

ASP.NET MVC 2 Beta: DateTime conversion. Bug or not?

<%= Html.ActionLink(Html.Encode("user3"), "Filter", new { controller = "Search", userName = "user3", dateFrom = DateTime.Now.AddDays(-2).ToString(), dateTo = DateTime.Now.ToString() })%> It's evaluated to this link: http://localhost:60357/Search/Filter?userName=user3&amp;dateFrom=08.02.2010%2023%3A21%3A33&amp;dateTo=10.02...

help designing autocomplete response's

I want my autocomplete to be very user friendly. I have products that people will search for by: part# manufacturer e.g. searches HND123 Honda 123 So basically each manufacturer has a short form and a long form. How should I build my search index so when the autocomplete needs to fetch the data from the db, it will return result...

Tracking Logged on Users

Hello All, On a project I'm building for a client, one of the requirements is advanced user tracking. The client would like to know what pages an authenticated user is visiting, and when. I read through this post, which is probably the method I will go with. However, that seems a bit tolling on the database, and being that the client...

Uneditable ViewModel properties in a edit view

In my ASP.NET MVC2 application, I have a ViewModel class called UserCreateViewModel. In this class, there are a number of properties that directly map to a LINQ-to-SQL class, called User. I'm using AutoMapper to perform this mapping and it works fine. In my Create action of the UserController, I receive a partially complete UserCreateV...

Redirecting to force parameter in url (MVC)

I am working on a multilingual website where the URL will contain the language code: /en/Home /es/Home Whenever someone enters a url that does not have the language code at the beginning (/Home), I would like to do a 301 redirect to the url (route) they entered but append the language code at the beginning. I will determine the langua...