asp.net-mvc

jQuery callback happening too fast?

Hi, I am using ASP.NET MVC C# I have a jQuery call that deletes a Book, then in the callback I call a function that refreshes the list of Books. function rembook(id) { var agree=confirm("Deletion cannot be undone. Continue?"); if (agree) { jQuery.ajax({ url: "/Books/Delete/" + id, dataType: null, t...

Overriding updatecollection in defaultmodelbinder

I'm having a problem with the default model binder creating new entities when I bind a entity with child collection rather than updating the existing child entities. I found what looks like a good solution in this post link text but I don't want to have to change the mvc source. Can someone tell me how I could override this method in...

How can I make Input Builders (MVC Contrib) work with Spark View Engine?

Today I spent a good three hours trying to convert the project MvcContrib.Samples.InputBuilders, included in MVC Contrib to make it work with Spark View Engine, but so far was unable to do so. Does anybody have a clue why these two just won't get along? Changes I've made InputForm.spark: <viewdata model="SampleInput" /> !{Html.InputF...

In ASP.Net MVC, what is the best way to do an update from a dialog?

I'm trying to combine 2 parts of MVC that I haven't seen used together: 1) Ajax and 2) Error handling. The problem lies in what is returned and where (div element to update) that it's returned. I have an ASP.net MVC page that looks like the following <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<Store>" %> <div id="MainPage...

T4 Controller Template to trigger View Generation

I have been using some customized MVC templates that really improve my productivity. However, I would like to take it to the next level. I generate a controller template for each table in my app. The controller has Edit, List, Details, and Delete actions. What I would like to do, is at the same time trigger the generation of the view...

how to connect to a sql server database in asp.net mvc

Hai guys, how to connect to a sql server database in asp.net mvc ... I know it can be done easily in asp.net web application using web.config and in the aspx page System.Configuration.ConfigurationManager.ConnectionStrings["database"].ConnectionString; ...

Allow RESTful DELETE method in asp.net mvc?

im currently setting up asp.net to accept DELETE http verb in the application. However, when i send "DELETE /posts/delete/1" i always get a 405 Method not allow error. I tried to take a look at the header: Response Headers Cache-Control private Pragma No-Cache Allow GET, HEAD, OPTIONS, TRACE Content-Type text/html; charset=...

MVC v2 preview 2, Is it stable enough for production use?

Hi Is anyone out there using MVC v2 preview 2 out in production yet? Can anyone make comments whether this version is good enough/or they have used this for use in production code? Should I stick with version 1 and wait for the official release? ...

ASP.NET MVC Action is Called Twice

I have a specific controller action that is being called twice, which aside from being weird is causing problems with a singleton portion of my application (not really a problem, it just brought the double call to my attention). Any idea why a controller action would be executed twice every time? ...

Exception Handling with Structuremap

Is there anyway to recover gracefully in an ASP.NET MVC application if the database is not found for some reason when I try to get an instance of my NHibernate Session from Structuremap? public static class StructureMap { private static Configuration Cfg { get { var configuration = new Configuration()...

MVCContrib, Html.Grid: How can I attach a row-based id to a td tag?

Here's my current view code: <% Html.Grid((List<ColumnDefinition>)ViewData["Parameters"]) .Columns(column => { column.For(c => c.ID); column.For(c => c.Name); }).Render(); %> I'd like to attach an HTML "id" attribute to each "name" td tag as such: <table class="grid"> <thead> <tr> <th>Id</th> ...

Request.IsAjaxRequest returning false on POST

My question is similar to this one and I am having a similar issue, but a big difference is that I'm using the Ajax helper methods (Ajax.ActionLink and Ajax.BeginForm) instead of handling the AJAX with jQuery. Request.IsAjaxRequest() is returning true for the Edit method that accepts http GET, but false for Edit method accepting http P...

Flash slideshow in ASP MVC

Hi everybody! Never had to do some ...Flash stuff, but now a customer wants me to make a Flash intro in her (ASP MVC) site! The scenario is this: images are stored in the dbms. Every image belongs to a category. Depending on what category is selected, the corresponding images should be fetched and played in a flash player with "transit...

Gradually migrating Classic ASP 3.0 to ASP.NET MVC

I'm evaluating a migration from a classic ASP 3.0 application to ASP.NET MVC. I've already migrated applications to WebForms, but have decided to try MVC for this migration for a number of reasons, including the fact the code in this application is NOT spaghetti and seems to lend itself to an MVC style layout. One major constraint on th...

ASP.Net MVC RouteData and arrays

If I have an Action like this: public ActionResult DoStuff(List<string> stuff) { ... ViewData["stuff"] = stuff; ... return View(); } I can hit it with the following URL: http://mymvcapp.com/controller/DoStuff?stuff=hello&amp;stuff=world&amp;stuff=foo&amp;stuff=bar But in my ViewPage, I have this code: <%= Html.ActionLi...

mvc and img tags, which to use?

when specifying the src of an img tag, must i convert the relative path to absolute? please post examples and why not use runat="Server" ...

How do I make sure a file path is safe in C#?

I have an asp.net mvc app with a route that allows users to request files that are stored outside of the web application directory. I'll simplify the scenario by just telling you that it's going to ultimately confine them to a safe directory to which they have full access. For example: If the user (whose ID is 100) requests: http://m...

Why does not specifying view name cause my unit test to fail?

In my unit tests, I find that when I return from a controller action using View() with no view name, ViewResult.ViewName is set to string.Empty. In order for this to be set, it has to be specified as a parameter to the View() call. For example, given the following unit test: [TextFixture] public class MyControllerTests { [Test] ...

ASP.NET MVC: Using GET and POST in the same method

Here's the scenario: when a new user registers to our web site, we want to send an email to verify that the user owns the email address. In the email there's a link to a page that will do the verification, something like this: http://www.mysite.com/account/verify/token The verify method looks like this: [AcceptVerbs(HttpVerbs.Get)] pu...

What's the best practice for ASP.NET MVC app to check for dependencies at startup?

Like any other ASP.NET application, the web app I'm developing depends on a plethora of services and settings. Examples of services include third-party web services and examples of settings include SMTP server settings. It is fairly typical for a Java application to do some self checking at startup and if any of the required dependencie...