asp.net-mvc

Cannot redirect after HTTP headers have been sent

Hi Guys, I'm using MVCContrib and its EmailTemplateService to send html email. Send email works fine but it doesn't seem to dispose email view properly. When I try to redirect to a new Action it gives the following error: "Cannot redirect after HTTP headers have been sent" Does anyone know how to fix this problem. Many thanks Sandra...

How do I pass a list from aspx to javascript?

I have a list that I loop through to populate my table. I would like to pass a row of data to my javascript code at best. If not, I would like to pass the list and the id number to search for that row in the list. How can I do this? <%foreach(var item in Model.NewList) { %> <tr> <td><%=item.EntryDate.ToShortDateString() %></td>...

Use a different controller's action for the Index action of the Home Controller

I think this is a pretty common scenario, but I haven't been able to phrase my problem in such a way that I have generated any useful search engine results. I'd like the Index action of my HomeController to return the action from a different controller. I have come up with a few solutions but have dismissed each for various reasons: U...

Can an ASP.NET MVC2 site have an optional enum route parameter? If so, can we default that value if not provided?

Hi folks, can I have a route like... routes.MapRoute( "Boundaries-Show", "Boundaries", new { controller = "Boundaries", action = "Show", locationType = UrlParameter.Optional }); Where the action method is... [HttpGet] public ActionResult Show(int? aaa, int? bbb, LocationType locati...

asp.net mvc returning an image in an iframe

what i want i want to return a complete image from the controller that is uploaded. i want to display the complete image returning as the part of iframe response. here is my view code to get the idea. can it be done? Currently it is returning a string that a file is uploaded or not? <form action="<%= Url.Action("FileUpload", "Organiza...

asp.net mvc virtual directory problem

Hi, I'm having difficult with a small MVC app that we've used as an exercise in using ASP.NET MVC. I had it set up as a website on one of our IIS6 servers, which worked fine. We needed to force authentication, so I now want to put the application in a virtual directory under our main DNN intranet site. It at first complained that it ...

DotNetOpenAuth + MVC2 + Google App Standard

Hi, I'm trying to authenticate users to my ASP.Net MVC2 app throw a google apps standard edition account. I could not found examples nor documentation to achieving. I looked into DotNetOpenAuth Samples Solution, but did not found an example according my needs. All the examples were working against google accounts, but no with google app...

.NET MVC - How to utilize custom settings provider?

I have created a custom settings provider to store my application settings in a separate XML file. I've created settings and values through Visual studio (Solution -> My Project -> Settings) and specified my custom provider. It doesn't seem to be 'used' by the application. I can put breakpoints everywhere in my custom provider, but they...

How can I render MVC Actions in parallel to decrease overall rendering time of page?

I have a page that has a bunch of widgets on it. Each widget is a view. Right now the widget rendering is done in a foreach loop like so. public class WidgetCollection : List<Widget>, IPersonalizable { public void Render(HtmlHelper html) { foreach (Widget w in this) { html.RenderAction("D...

Can't find the custom error page

Here's how I have it defined (locally, on my development machine): <customErrors mode="On" defaultRedirect="Error.aspx"> <error statusCode="404" redirect="NotFound.aspx" /> </customErrors> And I have the [HandleError] attribute: [Authorize] [HandleError] public class HomeController : Controller { // etc. Yet when I ...

ASP.NET MVC/Entity Framework: Accessing aggregate objects through the aggregate root repository

I'm in the process of building my first web application using ASP.NET MVC 2 and the Entity Framework. I am using the repository pattern. From information I have gathered on Stack Overflow and other websites it appears that the consensus is to have one one controller per domain model object and one repository per aggregate root object. T...

HtmlHelper building a dropdownlist, using ServiceLocator : code smell ?

Is it a code smell to have to following pattern, given the following code (highly simplified to get straight to the point) ? The models : class Product { public int Id { get; set; } public string Name { get; set; } public Category Cat { get; set; } } class Category { public int Id { get; set; } public string Label ...

How to remove ASP.Net MVC Default HTTP Headers?

Each page in an MVC application I'm working with sets these HTTP headers in requests: X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 X-AspNetMvc-Version: 2.0 How do I prevent these from showing? ...

asp.net mvc adding css to editorfor?

Hi, I'd like to change style of the 'editor for' textbox from MVC, specifically I want to make the textbox larger. I've tried adding css a few ways, to no avail. including : <td class="myCss"><%=Html.EditorFor(x => x.NickName)%></td> and <%=Html.EditorFor(x => x.NickName, new { @class = "myCss" })%> help pls! ...

How to implement a tab control where each tab is a generic paged entity?

Background: I'm trying to implement a tab control. The tabs are as follows: | Funds | Companies | Groups | and are implemented as follows: <ul class="ActionControl"> <li> <%=Html.ActionLink(string.Format("Funds ({0})", Model.Summary.FundCount) , "ResultsList", new {selectedTab = "Funds"} ) %> </li> //...

Handling a scenario of an unavailable database in an MVC application.

In this scenario I wish too bypass my normal error logging, which wont work, and simply request the Error view and and send an email. I don't wish to duplicate this special case handling in all controllers, and DB access might be attempted before any action is requested. Where should I place this special handler, and if not in a contro...

How do I need to hit the controller on change on radio button using jquery

Hello Friends, I have a questions.. when initially page load I have two radio button in the page.. Add Edit when I select Add radio button I need to go the controller Action Add $("#Add").change(function () { // what should I write here to hit the controller? }); Thanks ...

Will ASP.Net MVC's AntiForgeryToken Method work with Load Balancers?

Using ASP.Net MVC v2.0, I am starting to research the use of the Html.AntiForgeryToken() method when submitting forms that process data. I can see it sets a hidden value in the form HTML and it sets the same value in a session cookie. The question is will different web servers in a load balanced configuration create the same token in t...

ASP.NET asynchronous controllers and calling Sync(); what is "Sync()"?

The Working with the BeginMethod/EndMethod Pattern section of Using an Asynchronous Controller in ASP.NET MVC refers to a Sync() method. It is not linked and I am having trouble finding documentation on it through google searches since sync is too common a term. Can someone point me in the write direction? To make sure that you have...

Is there a way to rename the RequestVerificationToken cookie name?

Using ASP.net MVC v2.0, Any way to change the name of the __RequestVerificationToken cookie? In an effort to conceal our underlying technology stack, I’d like to rename the cookie to something that can’t be traced back to ASP.Net MVC. More info on this at Steve Sanderson's blog. ...