asp.net-mvc

Subsonic3 and ASP.NET MVC: Is there something like DataContext.GetTable<T>?

Right now I'm working my way thru the SportsStore exercise of Sanderson's "Pro ASP.Net MVC 2 Framework" book (page 107) and the exercise has me implementing a Repository pattern backed by a DB store using LINQ-to-SQL. I'm trying to figure out how to implement this same repository with the Subsonic ORM. The basic repository code is as fo...

Generating a client URL in a Timer running in global.asax

I have an MVC 2 app that has a System.Timers.Timer object starting up during Application_Start in global.asax. One of the things this timer needs to do is generate a daily e-mail to users when they have an item to review in their work queue. Inside the e-mail is a link back to the item to review. In code I have running in various cont...

How to handle callbacks in asp.net ?

Are there different callbacks available in aps.net like rails provide before_validation, before_update, before_save and before_destroy ? How to handle this scenarios in aps.net ? ...

C# and JavaScript results from same regular expression string are very different - how can I make results more consistent?

The reg ex string is as follows: px\">(.+)</SPAN When I use this code with this expression in C#, and compare with the body of an html document, I get back a short string like so: Match match = Regex.Match( fullText, regExString, RegexOptions.IgnoreCase ); .. gets px">Cart is empty </span><a href="http://www.somesite.co.uk/shop/ca...

ASP.NET MVC/C#: Can I avoid repeating myself in a one-line C# conditional statement?

Consider the following code that I'm using when displaying a Customer's mailing address inside a table in a view: <%: Customer.MailingAddress == null ? "" : Customer.MailingAddress.City %> I find myself using a fair amount of these ternary conditional statements and I am wondering if there is a way to refer back to the object being ev...

Word-style autotext functionality for text and textarea inputs

I've been asked to support an autotext functionality on our web application, similar to what Word offers. At the core this is simple automatic text search-and-replace as someone types, but there are lots of things that would be nice (backspace to undo the replacement, a pop-up that requires a tab or enter to insert the replacement, etc....

MVC2 Handling Exceptions from RenderAction

My controller is decorated with [HandleError] and [HandleError(ExceptionType=typeof(CustomException), View="CustomView")]. I have views that consist of multiple partial views from multiple controllers, so we're displaying our partial views using <% RenderAction(...) %> but now we have a case where our action being rendered is throwing a...

overload ActionResult

this is my action "Index" when i first go to page i dont have the "pageParent" so i dont get the page. just if i enter to it like this "http://localhost:50918/Page?pageParent=1" it's enter. how to make "http://localhost:50918/Page" to work? public ActionResult Index(int pageParent) { var id = pageParent; var pages...

RESTful MVC Web Service and AspBufferLimit

I have a RESTful web service built on the MVC framework (ala Aaron Skonnard) where methods may return > 4MB of XHTML. I don't want to bump up against the 4MB ASPBufferLimit, and so I'm planning to use the Controller.File() method as shown below -- note the "text/html" trick. In the past, I've written a loop to pump large streams out us...

ASP.NET MVC - Prevent Double Form Posting.

I have an ASP.NET MVC Form, but the data from it needs to be posted via jQuery (not ajax). It cannot be submitted using the normal model, because the Controller Action requires a JSON string, and the only way to get that string is to use jQuery's $.post method to turn the data into JSON, and then post it to the Controller. This works fi...

Expose WCF services that belong to an Area in MVC app at a routed path

I've got a WCF service (lets say TestService.svc sitting inside the services directory of an Area in an MVC app. This area is combined into the main app. The area is called content. The routes have been setup and the area works fine. To access the Index action on the Home controller I can do either: http://my-host/areas/content/inde...

Render partial view with dynamic model in Razor view engine and ASP.NET MVC 3

When I try to render a partial view whose model type is specified as: @model dynamic by using the following code: @{Html.RenderPartial("PartialView", Model.UserProfile);} I get the following exception: 'System.Web.Mvc.HtmlHelper<dynamic>' has no applicable method named 'RenderPartial' but appears to have an extension method by tha...

ASP.NET MVC - Ensure Data Integrity

Hello, I have encountered what I expect is a common issue in web development. I have an ASP.NET MVC 2.0 ecommerce site. I pass the cost of an item to the product page view via a viewmodel - this cost may vary based on user type, user history, quantity purchased, etc. I want to guarantee that when the user submits the form to purchase ...

How to set a Razor layout in MVC via an attribute filter?

I'd like to set a default Razor layout via code in either a base controller or an attribute. It was mentioned in the Docs that this is possible, but I can't figure out how it's done. I know there's the masterPage parameter to the View method available, but I would like all views returned by a controller to have this value set automatica...

Any ASP.NET MVC-friendly chart controls that support pie charts with different slice radii?

I need to create a sort of pie chart that has slices with differing radii - similar to: http://www.andypope.info/charts/pieradius.htm. I also want to overlay a second series on it, as a line. The solution needs to be ASP.NET MVC-friendly - and I need to be able to associate "drill down" links with the slices. If there's no off-the-...

Create short permalinks similar to Stack Overflow's "short permalink to this question"

I think I might already understand how this works, but wanted to be sure. I am in the process of defining the routes for a new ASP.NET MVC application. I'd like to create short permalinks similar to Stack Overflow's short permalink to this question: http://stackoverflow.com/q/4047890/61654 What route and controller mechanism is S...

EF4 Object State Manager is claiming multiple entries are attached when there aren't

I am trying to add functionality in my ASP.NET MVC app to change some fields of my data structure. After clicking the submit button on the form, the following action is called: [HttpPost] public ActionResult Edit(Document doc) { // Attempt to save the project if (_documentService.SaveDocument(doc) == Service...

MVC2 referencing external JavaScript file from Master Page

Hi, What is the correct way to absolute reference an external JavaScript file from the Site.Master file. In Web Forms I used to do it like this src="<%#ResolveUrl(@"Scripts/Common.js") %>". Thanks ...

best practice for what is in a ViewModel

I am wondering if it is a good idea or bad, placing things like a List of countries in ViewModel, for binding to a drop down list? For example on a site's Registration page. I was under the impression that a ViewModel is supposed to represent an instance of the filled out form, but I think I may be wrong as I have seen other people put ...

Visual Studio Async CTP - Working with ASP.net MVC

The new Async framework released today at PDC10 looks really brilliant. I've had quite a bit of experience working with asynchronous applications/services and can say from experience that it is amazingly how simplified they have made the process. My question is - will this play well with ASP.net MVC asynchronous controllers? If it doe...