asp.net-mvc

Inject Multiple MembershipProviders with Structuremap

I have an existing ASP.NET MVC application and am using StructureMap as my IOC container of choice. Currently when a controller needs an IMembershipProvider I use StructureMap to inject a concrete instance in the controller's constructor based on the BuyerMembershipProvider configuration from my web.config file as in the below solution c...

What is the basepage equivalent in MVC

In my ASP.Net web sites I have the following code that I am able to use site-wide. How do I do the same in ASP.Net MVC2? public class BasePage : Page { public BasePage() { this.PreInit += new EventHandler(BasePage_PreInit); } /// <summary>Every page executes this function before anything else.</summary> protected void BasePage...

How to find out from where was Action routed to in ASP.NET MVC?

I don't think title is making any sense, so I hope that I can explain it well enough. I have Controler Item with Action EditItem. EditItem is routed to from many places, such as /Item/Browse/ByCategory /Item/Browse/ByType /Item/Browse/ByWhatever What I'd really like is to return the user to page from where he clicked Edit on an item...

ASP.NET MVC URL generation extensibility points

What are extensibility points of URL generation in ASP.NET MVC? Routes - virtual path depends on it ??? Addendum 1 Particularily, I need to control not only path part of URL but the host also. And I'd like to embed my generation logics into MVC Framework so that any call to standard Html.ActionLink method would involve my logics. It ...

IValueProvider in MVC 2 RC 2

I have been working with MVC 2 and it seems that at some point of time the ModelBindingContext.ValueProvider class has been removed and replace with IValueProvider. Because of this im having trouble iterating through the ValueProvider.Keys. Here is an example and the message I receive from Code complete private void foo(ModelBindingCon...

Is it possible to host a asp.net mvc website from a winforms application?

I have a winform application that controls some transmitters and sound cards. There is a requirement to be able to provide a web interface for controlling those devices. Currently I use WCF to communicate from the controllers in my asp.net MVC site to the winform app. That works well, but there is now a desire to move the hardware to ...

What to use for Custom Account Control in ASP.NET MVC.

I'm creating a custom authentication service (I just need more than the default allows). I can't decide if I should extend MembershipUser and implement the appropriate interfaces, or completely roll my own. Is there any advantaged to rolling my own, or any pitfalls I should be aware of when extending the default mechanism? ...

asp.net mvc Can i have one view for multiple action methods to target? or do i need a separate view for each?

Hi, I have set up a menu-controller to drive the top menu links based on which other controller is being used. Each other controller has a separate nested master page for each of its views. so, i have a menu-controller with several methods that return viewresults, one per each controller, or "section" of the site. So currently each o...

Asp.net MVC using the same controller for multiple routes

I have a simple controller like this (no, not really, but let's say I do) public class SomethingController : Controller { public ActionResult Method1() { return View("Something1"); } public ActionResult Method2() { return View("Something2"); } } Now I want to use this controller with two different rout...

Should I use POST or DELETE verb in jQuery.ajax() function

This is from jQuery API docs: typeString Default: 'GET' The type of request to make ("POST" or "GET"), default is "GET". Note: Other HTTP request methods, such as PUT and DELETE, can also be used here, but they are not supported by all browsers. I am going to make AJAX delete links with jQuery. What I would like to know is spe...

HttpPostedFileBase.SaveAs method question

Hi all, I've got an asp.net mvc application that uploads a file and stores them in one of the directories where the website is located. My question is... When you execute HttpPostedFileBase.SaveAs() method saving it with the same name as an existing filename on the folder, does HttpPostedfileBase overwrite the file? Thanks a million!...

How do you unit test HTML.ActionLink

I would like to be able to unit test that an HTML.ActionLink or Url.Action will return the correct url based on my route. What is the best way to achieve this. ...

ASP.NET MVC ViewPage rendered in a ViewPage

I'm wondering if it is possible to render a ViewPage inside of a ViewPage. Normally, you'd have this: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<my_object>"%> and then in the page you can render a user control: <%Html.RenderPartial("~/Views/Shared/mycontrol.ascx", this.ViewData);%> However I'd like to render a ViewPa...

ASP.NET MVC 2.0 - IList<T> CheckBoxes

What is the best way to handle this: class Option { int id; string name; } class QuoteItem { IList<Option> options; } class QuoteViewModel { IList<Option> allOptions; QuoteItem quoteItem; } Basically, I have all the available options in allOptions. I want to have a checkbox that puts another Option (even if it...

Generating a link containing a fragment with ASP.Net MVC Routelink

I'm trying to use Html.RouteLink within a view to generate a link to a named anchor on another page. There's a few definitions for RouteLink that include a fragment option but I'm trying to figure out if there's another way. public static string RouteLink( this HtmlHelper htmlHelper, string linkText, string routeName, st...

"Name 'Url' is not declared" when I try to use Url.Content()

I have an ASP.NET site that is not currently using MVC but I'm trying to convert it to MVC slowly. The first time I tried using Url.Content in an .aspx page I got: Name 'Url' is not declared I then added: <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> and: <add namespace="Syste...

What is an MvcHtmlString and when should I use it?

The documentation for MvcHtmlString is not terribly enlightening: Represents an HTML-encoded string that should not be encoded again. It's not clear to me what exactly the implications of this are. It seems that some HTML helper methods return an MvcHtmlString, but several examples I've seen online of custom helpers just return a r...

SparkView Engine on Linux Mono

I'm trying to use SparkView engine with ASP.NET MVC running on a Linux machine, but there seems to be known problems resolving view paths eg: System.InvalidOperationException: The view 'Index' or its master could not be found. The following locations were searched: ~/Views/Home/Index.aspx ~/Views/Home/Index.ascx ~/Views/Shared/Index.asp...

Visual Studio Web Application edit source while running like in Tomcat\Eclipse\Java

In an ASP.NET Web Site project, I've always been able to make changes to the underlying C# code and simply refresh the page in the browser and my changes would be there instantly. I can do the same thing when working with Java and Eclipse - edit my Java source and refresh the page and my changes are there. I cannot do this in ASP.NET M...

Spark View Engine and using viewdata confusion

I can't seem to get a grasp on how to use the viewdata structure in the spark view engine. I have the following code in my controller: // Retrieve the project list from the database var projects = from p in _context.Repository<project>() orderby p.name ascending select p; ...