asp.net-mvc

How would you architect visitor and admin functions in a single ASP.Net MVC web application?

So I have been working on a small web application (site) for a group of friends of mine and have come to the realization that things need to change. The application has two faces to it a public facing side that serves dynamic data to visitors and non admins, and an admin side where admins can update or create the dynamic data to be ...

How do you get access to the current System.Web.Routing.RequestContext from within a custom helper method in ASP.NET MVC?

I'm writing a helper method for ASP.NET MVC and I need to call Url.Content to get an appropriate URL for the context. However, in order to create a new UrlHelper() I need to get the current RequestContext (System.Web.Routing.RequestContext to be precise) and I'm not sure how to grab it. Anyone know? ...

How do I create a ListBox in ASP.NET MVC with single selection mode?

How do I create a ListBox in ASP.NET MVC with single selection mode? ...

How can I trick MVC into rendering links based on a different virtual path?

I'm running a bunch of apps on discountasp.net with the subdomain addon. Since with shared hosting I can't have multiple IIS sites, I've also written an HTTP module that allows sites in subfolders to operate as if they are running in the root directory. So for example, instead of hosting my blog at dandoes.net/blog, I can host it at blog...

Sharing Views

Is it a good idea to share views between different controllers (using the Views/Shared folder)? I am creating my first MVC application and it requires some pieces of data that are similar to each other. They "explain" different things (and will therefore be stored in different tables) but they each have an Id, Name and Status. I can ther...

In ASP.NET MVC how can use I Url.Content() from code?

I'm trying to write a custom helper method that will output an image tag but I need to access something like Url.Content() to get a proper URL for the current context. Is there any easy way to do something like this? ...

asp.net mvc - name space in view

i place using name space in view code behind but i can't call any class of this name space in aspx. in code behind: using MVCTest.Controller; ...

Pass URL as get parameter?

I'm trying to pass u url as parameter to a get method. I defined a route that accepts a {*url} parameter so I can send "/" characters without it separating my parameter. As soon as there is a ":" in the url (like in http: or localhost:3857 for example), the method never gets hit. The Html.ActionLink method escapes it's parameter itself,...

Oxite: What are you going to do with it?

Microsoft released the source for Oxite, their blogging engine that's intended to help .NET developers learn ASP.NET MVC. They also released the source for the Mix site, which was built with Oxite. Microsoft says that developers can build applications with Oxite, since it has a lot of built-in features like trackbacks, pingbacks, and RS...

MVC + IIS7 = CSS Issue...

I have a web site running via IIS7 on Vista. The site is running on port 88, so http://localhost:88 should render the default /Home/Index view. This works correctly, as do all other views. However, one problem is resident. My script paths point to /Scripts/[FILE] and my CSS paths point to /Content/[FILE]. My assumption was that the /...

ASP.NET MVC Beta Project can't create controller tests properly in subfolder

I'm using VS2008 Team Suite, ASP.NET MVC Beta, with TestDriven.Net installed. When I created my project from the template, it created a "Tests" project as well and put some controller tests for the AccountController in a folder inside this project. I've added other controllers and associated tests. Howerver, when I right-click on a met...

Asp.Net MVC routing: best way to have a single element in the URL?

I will take the example of the SO site. To go to the list of questions, the url is www.stackoverflow.com/questions. Behind the scene, this goes to a controller (whose name is unknown) and to one of its actions. Let's say that this is controller=home and action=questions. How to prevent the user to type www.stackoverflow.com/home/questio...

Get current request's credentials for using in WebRequest

When accessing my site, the user has to enter his credentials. They are basically plain directory access credentials. At a certain point I check if a certain file they want to download exists by calling WebRequest req = HttpWebRequest.Create(checkUri.AbsoluteUri); WebResponse res = req.GetResponse(); Although I can access the checkUri...

ASP.NET MVC public alternative to UrlHelper.GenerateUrl

I want to embed a link to a controller action in my page so I can use it from javascript. Something like var pollAction = '/Mycontroller/CheckStatus' Now I am happy to hardcode it, but it would be really nice if there were a method I could use to create the URL. The AjaxHelper/HtmlExtensions contain methods to create hyperlinks (.Acti...

ASP.Net MVC HandleError throwing 500 Internal Server Error

Hi folks I have the following HandleError filter on my controller: [HandleError(ExceptionType = typeof(ArgumentException), View = "DestinationError")] I've set-up the Web.Config so that customErrors are on. The problem I'm having is that the HandleError filter is working fine, when I run the app locally out of Visual Studio, but when...

OutputCache and recording unique views?

Hi folks, Image i have a view that is cached with the OutputCache attribute but i still need to increment a counter that records that the page has been viewed, how could i do it? I thought about creating my own Custom ActionFilterAttribute, and using Action Filter Order of Execution to record this .. but i'm not sure it will work. eg....

[MVC] What's the preferred URL to add an entity that is not an aggregate root?

Example: an Order object (aggregate root) has a collection of OrderLine objects (child entities). What's the URL add an OrderLine to an Order? Take into consideration the difference between using the aggregate roots' controller and having a separate controller for the child entity. 1: http://example.com/orders/add-orderline?order-id=42&...

ASP.NET MVC Index vs. Index and List views

I'm developing my first ASP.NET MVC application. This application tracks events, users, donors, etc. for a charitable organization. In my events controller I support standard CRUD operations with New/Edit/Show views (delete is done via a button on Show view). But I also want to list all of the events. Is it better to have a List vie...

How to use multiple view engines in ASP.NET MVC application

Hi, I'd like to use two view engines in my asp.net mvc web application. The first one is the Brail view engine from MVCContrib project, and another one is my custom view engine for generating javascript code. However, I can't configure the application to use both engines. I'd like to use view file extension to discern which engine should...

How to redirect to a dynamic login URL in ASP.NET MVC

I'm creating a multi-tenancy web site which hosts pages for clients. The first segment of the URL will be a string which identifies the client, defined in Global.asax using the following URL routing scheme: "{client}/{controller}/{action}/{id}" This works fine, with URLs such as /foo/Home/Index. However, when using the [Authorize]...