asp.net-mvc

Getting rid of the /Home path name in ASP.NET MVC

Ive only just started using ASP.NET MVC, and I have a somewhat trivial question: it seems that each controller has an attached folder-like path, so that my site becomes mydomain.net/Home/something. Is it possible to somehow get rid of the /Home part, so that the Home controller becomes default for my web site and its possible to just use...

How do I access ViewData properties in my view?

I am building my first ASP.Net MVC based app and have a problem accessing the results of a linq to sql query in one of my views. Here is my controller: public ActionResult Details(int id) { var dataContext = new BuffetSuppliersDBDataContext(); var supplier = from m in dataContext.BO_Suppliers ...

How to get data from an IHttpModule to the ASP.NET MVC RequestContext?

I've got a custom IHttpModule that does authentication (to Facebook, Myspace, etc). It raises an event that can be handled in the HttpApplication instance with details about the user. It's a lot like the OnAuthenticate event that the FormsAuthenticationModule raises. From the HttpApplication class, where should I place this information ...

ASP.NET MVC Master Pages

What's the difference between the ASP.NET Master Page, and the MVC Master Page? And the AJAX Master Page for that matter? ...

ASP.NET MVC Version of Ruby on Rails "link_to_unless_current"

I want to include a link in my SiteMaster (using Html.ActionLink) UNLESS the view that I am linking to is the current view. For example, there is no sense displaying a "Register" link when the user is already seeing the "Register" view. In Ruby on Rails, I use the "link_to_unless_current" method to do this. How do I duplicate this beh...

Best practice for determining necessary controllers for simple ASP.NET MVC site?

I'm playing with the ASP.NET MVC Framework, trying to create a simple site. My model is essentially: -Questions -Answers -Categories Since each Question must belong to a Category and each Answer must belong to a question - is it correct to split 'Category' into it's own controller? What would be incorrect about creating a controller p...

UI composition in ASP.NET MVC

How would you go about supporting external composable parts in an ASP.NET MVC view? What do I mean by this? Think either "login box on every page" or "iGoogle". It's stuff that needs to be in certain places that is external to each controller/view. One approach at this would be adding components in the view like so: <% foreach (var c...

Moving MVC Beta Web application to Virtual Directory strips out all /Content resources

I have a very nice MVC Beta application developed using VS2008 on a win2008 server. My troubles began when I attempted to deploy it to an IIS6 virtual directory. After installing the MVC Beta on the target win2003 server box I was able to get the application to display from a virtual directory, but all images and css attributes are mis...

FormatException: Html.CheckBox(), UpdateModel() and the hidden input

i have my checkbox for a bool field like so in my view: =Html.CheckBox("Active", ViewData["Active"] != null ? ViewData["Active"] : (ViewData.Model.Active != null ? ViewData.Model.Active : false) you can forget the fluff if you like: =Html.CheckBox("Active", ViewData.Model.Active) ..causes the same problem. when i try to update my mo...

Best way to generate Json-friendly result (.NET MVC)

I'm now using ListItem() for Json format result, but the generated Json text has an extra property called "selected = false", I know this is used for drop down list, but I want my app runs faster so I don't want this property. Do you know any other way to get the similar result? Here is my code: List<ListItem> list = new List<ListItem>...

Should cs files be deployed when publishing an ASP.Net MVC application?

I have a project that compiles and runs fine on my development machine but when I run it on the web server I get the following error. Parser Error Message: The file '/Views/Shared/Main.master.cs' does not exist. The file mentioned does not exist on the server but the file '/Views/Shared/Main.master' does. I use the 'Publish' comma...

Forum for ASP.NET MVC site

Hi guys, I am buidling a new site for an organisation. I am using ASP.NET MVC. The previous site was PHP based and had a PHPBB forum. This forum opened in an IFrame, so no integration. We want a site with all functionality integrated. I thought, I probably have to write a forum myself. However there are other ASP.NET open source forums...

IIS7, SQL 2008 and ASP.NET MVC security

I have an ASP.NET MVC application that I'm working on. I've been developing it on Windows Server 2003 with IIS6 and SQL 2008 Express, and everything was working great. I recently decided to try out the Windows 7 beta, so now I'm using IIS7, and have run into a problem with connectivity to my database that I can't seem to figure out. I c...

What are my options for a nice and simple validation of Models and UI inputs with asp.net mvc?

I am looking for a validation framework that can handle the validation of my business objects and also UI inputs. Preferably i want to not repeat my validation logic too much and try to use the DRY principles. So the ideal place would be my biz objects. What have other ppl used? Also i've heard about the IDataErrorInfo, does anyone h...

multiple resultsets in c# MVC

I am using Asp.NET MVC as a basic webservice for several searchengine type asp/ jquery sites. Database searching is straightforward: Model - Sql Server FullText Sproc returning XML View - N/a Controller - Authorise user/ Parse input return Content (Model.XML) The returned XML contains four resultsets - item list, category breakdown,...

Is it possible to run ASP.NET MVC routes in different AppDomains?

I am having problems with thinking up a solution for the following. I got a blog which I recently upgraded from web forms to MVC. The blog is avalible in both swedish and english on two different domains and are running in the same web site in IIS. The problem is that I would like language specific urls on the both sites, like this: En...

ASP.NET MVC - Multiple models in a form and model binders

I have a form which needs to populate 2 models. Normally I use a ModelBinderAttribute on the forms post action i.e. [Authorize] [AcceptVerbs("POST")] public ActionResult Add([GigBinderAttribute]Gig gig, FormCollection formCollection) { ///Do stuff } In my form, the fields are named the same as the models pro...

Adding the results of two queries to ViewData.Model

I have the following code in my controller: public ActionResult Details(int id) { var dataContext = new BuffetSuppliersDBDataContext(); var supplier = (from m in dataContext.BO_Suppliers where m.SupplierID == id select m).FirstOrDefault(); ViewData.Model =...

Does asp.net remove <script> tags in repeaters and inside the <% for loop %> in mvc

I have some script type="javascript"/script tags inside both a repeater and a for loop in mvc. On page render the script is gone and is not displayed both inside the repeater and the for loop (they are separate). Is there some option I need to set to stop this from happening? Has anyone had this happen to them? ...

ASP.NET MVC - Routes and UrlHelper

I have the following route routes.MapRoute( "GigDayListings", // Route name "gig/list/{year}/{month}/{day}", // URL with parameters new { controller = "Gig", action = "List" }, new { year = @"^[0-9]+$"...