asp.net-mvc

ASP.NET MVC & Web Services

Hello, Does adding a Web Service to my ASP.NET MVC project break the whole concept of MVC? That Web Service (WCF) depends on the Model layer from my MVC project to communicate with the back-end (so it looks to me like it needs to be part of the MVC solution). Should I add this to the Controller or Model layer? ...

How to pass context around in a ASP.NET MVC web app

Ok, I'm a newbie to ASP.NET web apps... and web apps in general. I'm just doing a bit of a play app for an internal tool at work. given this tutorial... http://www.asp.net/learn/mvc-videos/video-395.aspx The example basically has a global tasklist. So if I wanted to do the same thing, but now I want to maintain tasks for projec...

How to customize directory structure in ASP.NET MVC?

The project I'm starting to work at will have several dozens of controllers, so it would be nice to structure them into logical directories and respective namespaces, like "Controllers/Admin/", "Controllers/Warehouse/Supplies/", etc. Does ASP.NET MVC support nested controller directories and namespacing? How do I manage routes to those...

How do you structure your URL routes?

Is there a specific pattern that developers generally follow? I never really gave it much thought before in my web applications, but the ASP.NET MVC routing engine pretty much forces you to at least take it into consideration. So far I've liked the controller/action/index structure (e.g. Products/Edit/1), but I'm struggling with more c...

ASP MVC Preview 5 and IIS 6 Windows Authentication

I've just built a basic ASP MVC web site for deployment on our intranet. It expects users to be on the same domain as the IIS box and if you're not an authenticated Windows User, you should not get access. I've just deployed this to IIS6 running on Server 2003 R2 SP2. The web app is configured with it's own pool with it's own pool user ...

Stuck creating a "security trimmed" html.ActionLink extension method

I'm trying to create an Extension Method for MVC's htmlHelper. The purpose is to enable or disable an ActionLink based on the AuthorizeAttribute set on the controller/action. Borrowing from the MVCSitemap code that Maarten Balliauw created, I wanted to validate the user's permissions against the controller/action before deciding how to r...

ASP.Net MVC Keeping action parameters between postbacks

Say I have a page that display search results. I search for stackoverflow and it returns 5000 results, 10 per page. Now I find myself doing this when building links on that page: <%=Html.ActionLink("Page 1", "Search", new { query=ViewData["query"], page etc..%> <%=Html.ActionLink("Page 2", "Search", new { query=ViewData["query"], page e...

Constructor parameters for controllers without a DI container for ASP.NET MVC

Does anyone have any code examples on how to create controllers that have parameters other than using a Dependency Injection Container? I see plenty of samples with using containers like StructureMap, but nothing if you wanted to pass in the dependency class yourself. ...

Working with client certificates for an ASP.NET MVC site on IIS 6

Wanting to implement authentication by client certificates I am experiencing some issues. First some facts The whole site is using SSL. I am using IIS 6 (on Windows Server 2003) and have configured the site to accept client certificates, not requiring them. Most browsers are however implemented in a way so that they will only ask the u...

What is the best practice for creating an ASP.NET MVC control or helper?

I'm looking to build an reusable control or custom helper for my MVC project. I'm sure there is a best practice for this. Any help is appreciated. ...

401 response code for json requests with ASP.NET MVC

How to disable standard ASP.NET handling of 401 response code (redirecting to login page) for AJAX/JSON requests? For web-pages it's okay, but for AJAX I need to get right 401 error code instead of good looking 302/200 for login page. ...

Setting placeholder properties from the controller?

I have an if/else statement in the controller and 2 different types of views to display depending on the outcome. So I have my 2 views in a .aspx page with a placeholder around each. How do I set the property placeholder.Visible from the controller? Or by the theory of MVC should I even be doing that sort of presentation in the control...

Does NHaml have a content_for ability for layouts?

I am currently starting a project utilizing ASP.NET MVC and would like to use NHaml as my view engine as I love Haml from Rails/Merb. The main issue I face is the laying out of my pages. In Webforms, I would place a ContentPlaceHolder in the head so that other pages can have specific CSS and JavaScript files. In Rails, this is done util...

What is the best practice for view file/directory structure in ASP.NET MVC?

I'm confused with how views are organized. Under the views directory, there are subdirectories. Inside these subdirectories are views. I'm assuming that the subdirectories map to controllers, and the controllers act on the views contained within their subdirectories. Is there an emerging expectation of what types of views are contain...

How can I make a framework for quickly building similar, but different, sites?

I have the need to build lots of sites that are very similar, but not exactly the same, using ASP.NET 2.0. I'm trying to find the best way to make generating these sites quick and easy. The sites will be used to collect information about a user, and there will be multiple steps for each site. The sites will all collect similar informa...

How do you RedirectToAction using POST instead of GET?

When you call RedirectToAction within a Controller, it automatically redirects using an HTTP GET. How do I explicitly tell it to use an HTTP POST? I have an Action that accepts both GET and POST requests, and I want to be able to RedirectToAction using a POST and send it some values. Like this: this.RedirectToAction("actionname", new ...

Overflowed (i.e. querystring) RouteData back out of the controller into the view

Anyone understand why the following doesn't work. What I want to do is copy current route data plus whatever I add via an anonymous object into new routedata when forming new links on the view. For example if I have the parameter "page" as a non route path (i.e. so it overflows the route path and its injected into the method parameter if...

Planning to use PostgreSQL with ASP.NET: bad idea?

Hi everyone! I'm currently planning the infrastructure for my future web project. I want to go the way Joel went with having one DB per client and now thinking which DB engine will be good for me. The best would be of course SQL Server, but I can't afford a full-blown version at this moment and I don't think SQL Server Express will be a...

What am I missing by not moving my ASP.NET 2.0 site to ASP.NET 3.5?

I have a web application using ASP.NET 2.0 and I want to know if I should be moving it to ASP.NET 3.5, particularly... what am I missing by not moving to ASP.NET 3.5? I understand the disadvantages, but I don't understand the advantages. What are the biggest benefits of migrating/rewriting? Will I get a speed improvement? Is MVC tha...

How do you unit test web page authorization using ASP.NET MVC?

Let's say you have a profile page that can only be accessed by the owner of that profile. This profile page is located at: User/Profile/{userID} Now, I imagine in order to prevent access to this page by other users, you could structure your UserController class's Profile function to check the current session's identity: HttpContext.C...