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...
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...
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...
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 ...
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...
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 ...
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?
...
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...
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...
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...
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!...
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.
...
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...
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...
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...
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...
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...
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...
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...
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;
...