asp.net-mvc

asp.net mvc Controller.RedirectToAction

protected internal RedirectToRouteResult RedirectToAction( string actionName, string controllerName); means I cannot do public static ActionResult RedirectToErrorAction(this Controller controller) { // redirect to custom error page return controller.RedirectToAction("error", "support"); } Any ideas? ...

How can I add an item to a SelectList in ASP.net MVC

Basically I am looking to insert an item at the beginning of a SelectList with the default value of 0 and the Text Value of " -- Select One --" Something like SelectList list = new SelectList(repository.func.ToList()); ListItem li = new ListItem(value, value); list.items.add(li); Can this be done? Cheers ...

ASP .NET MVC default routing problem RTW 1.0

I have just installed the RTW 1.0 of the MVC framework. I was using RC2 in the past to go through the tutorials. I now have a problem where basic routing doesn't work which i didn't have in RC2. If i create a new MVC application in VS 2008 the routings for the home page don't work out of the box. The following URL's work for some reaso...

asp.net mvc on asp.net 2.0 + ajax extensions 1.0 + iis 6 on win 2k3 server

I have a lot of problems with url rewrite and ajax extensions 1.0 on a asp.net 2.0 web application. I am considering using asp.net mvc. Does it work for me since i am using asp.net 2.0, ajax extensions 1.0 + ajax control toolkit, iis 6 on a win2k3 server? My development machine is windows vista with iis 7 Please advise. Thank you. ...

How to create a few radio boxes in ASP.NET MVC?

Hi folks, yeah :( simple question * blush * Lets imagine i have the following enumeration:- string[] languages = new string[] { "en (uk)", // English (colour) "en (us)", // English (color) "fr", // French "es" // Sp...

which is better? asp.net 2.0 stick with isapi rewrite or upgrade to 3.5 and use mvc?

Hi all, i have a asp.net 2.0 web app that runs with ajax 1.0 extensions and isapi rewrite. I have some bugs and i am considering whether to upgrade to 3.5 and use asp.net mvc instead. Please advise. ...

ASP.NET MVC: How can I get my actual object when using my Edit action?

Hi, I'm just starting to play with asp.net mvc and I've got a very basic question: If I have a view that shows information about System.Web.Mvc.ViewPage<Foo>, how can I get the actual object when passing the form values to my Edit Action on my FooController? By default I got this implementation of the Edit action: public ActionResult ...

Embedding View files as resource inside Binary

I am trying to create a .Net Library with few Controllers, and i want to reuse them in Multiple web projects. I'm half way through, But problem i'm getting is , Whenever i add the library to the new web project , i need to copy all corresponding view files separately to the new project. Whenever i update the library, i need to repeat th...

Unit testing ASP.Net MVC Authorize attribute to verify redirect to login page

This is probably going to turn out to be a case of just needing another pair of eyes. I must be missing something, but I cannot figure out why this kind of thing cannot be tested for. I'm basically trying to ensure that unauthenticated users cannot access the view by marking the controller with the [Authorize] attribute and I'm trying to...

ASP.NET MVC: How do I keep a field byte[]

I've got a field which its type is byte[]. This field will hold my entity's RecordVersion property (timestamp in the database). How do I keep this field so that when I save my entity it is available? I've tried two different things and haven't succeeded so far: This renders "System.Byte[]": <%= Html.Hidden("RecordVersion", Model.Record...

ASP.NET MVC jQuery AJAX Calls Action Method too late?

I have some jQuery code in an external Javascript file that is making an ajax call to an action method I have in my controller. The code in the external Javascript file is below. The action method is being called eventually, however it is not being called in time. When I set a break point in the action method, it is not being called u...

windows 7 asp.net mvc RC

i have a problem with asp.net mvc on windows 7... asp.net mvc RC was previously installed and i installed MVC rtm... it says “the project type is not supported by this installation”... is there anyway to register this project type in to visual studio or unregister the rc version? ...

ASP.NET MVC - Is there a way to simulate a ViewState?

Hi everyone! I have the following situation... In a certain View, the user must select the initial hour, the final hour and the weekday. But, I can't save this informations to DB 'cause I need to save my whole page and I need the primary key of the primary table, but that's not the point. So, while I don't save these data to DB, I'm sa...

IS there any application controller for .net mvc like ruby on rails?

I have some navigation things that need to hit the database every time a page has been requested. In Rails I would just set an instance variable in the ApplicationController.rb and that would be available to every controller/view. Now I see that all my controllers inherent from : Controller in .NET MVC. Can I open a partial class for Co...

Call methods between repositories - Repository Pattern

Hi, I'm using the Repository Pattern (like the examples in the http://www.asp.net/mvc site) in a ASP.NET MVC application. I have two repositories, one called CategoryRepository an other called ProductRepository. I also use two services, the CategoryService and ProductService to validate and call the repositories methods. I need a list of...

Does Silverlight 3 Change the MVC vs. Silverlight question?

I'm starting a new project soon and investigating whether or not to use MVC, Silverlight or both. This question Silverlight vs. ASP.NET MVC was a good starting point. But looking over the SL3 beta, it looks like there are two things that change the landscape just a bit. First, the navigation feature which is a direct feature of Silver...

Can you create a strongly typed ASP.NET MVC ViewUserControl of type int or enum?

Hi folks, i wish to create a reusable ASP.NET MVC ViewUserControl which is strongly typed to an enumeration. Can this be done? When i try it, it says that the strong type the ViewUserControl can accept, can only be of a reference type :( This also means i can't pass an int as TModel. Why do i want to do this? I'n various places of my...

ASP.NET membership provider on a different development machine

Is the "asp.net membership provider" portable? Do I have to run the aspnet_regsql.exe to set it up for every new machine? I imported the membership provider database to Visual Studio Database Edition and checked into my source control, and redeployed it to a different dev machine. From the new machine, I got the following error. How d...

Can ASP.Net MVC Views (*.aspx) be reused in multiple ASP.net MVC projects?

I would like to reuse *.aspx files in multiple ASP.Net MVC projects. Is this possible? EDIT: Anthony's suggestion of using version control system to share common files across multiple projects solves my question in a practical way. Luckily, since I'm using Subversion, the solution fits me. However, if I wasn't using one, how can this pr...

How would this be done in ASP.NET MVC?

I've got some experience with ASP.NET MVC, but only with a web application where the content of the master page doesn't change. I've been wondering how you would handle a site where for example the menu (which is on the master page) is loaded from a database. Where would you load this data? In WebForms, you would load the menu in the c...