asp.net-mvc

Routing with sub domains

I have an MVC website which has 3 main components Member area which has the path /Member/{controller}/{action}/{id} Individual pages which will respond to any subdomain, e.g. user1.example.com/{controller}/{action}/{id}, user2.example.com/{controller}/{action}/{id} Main website which will respond to any url under www.example.com/{contr...

Rebinding JQuery Event Handlers after MicrosoftAjax returns a PartialView

Hi All, I am playing around with AJAX functionality using ASP.NET MVC. I have created a page with a menu of categories generated from a database which when clicked makes an AJAX request to a Controller and then a Controller returns a PartialView. <% foreach (var item in Model.Categories) { %> <li> <%= Ajax.ActionLink(item.C...

How do I use Rhino.Mocks to mock a ControllerContext

I am trying to use Rhino.Mocks to mock up a ControllerContext object to gain access to runtime objects like User, Request, Response, and Session in my controller unit tests. I've written the below method in an attempt to mock up a controller. private TestController CreateTestControllerAs(string userName) { var mock = MockRepository....

ASP.Net MVC partial views keeping their model state?

This is probably again a newbie question. When I create an ASP.NET MVC2 application, an Account Controller with an Action LogIn is created like this: [HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { if (ModelState.IsValid) { if (MembershipService.ValidateUser(model.UserName, model.Password)) ...

ASP.NET MVC: How to avoid circular reference between 2 projects

Hello, My application has at least 2 projects, the OrganizationMangement and the ContactManagement. Previously, I referenced ContactManagement because I need to work with a class located in the OrganizationManagement. Now I need to do the reverse but I'm getting the following error "Cannot reference OrganizationManagement ... to avoid c...

Whats in the base class of ActionFilterAttribute?

Hi I am making an action filter to do a check and see if a user still has a valid key. I am just wondering what is in the base.OnActionExecuting(filterContext);? Like do I need to call it? Also where can I download the source for mvc 2.0? I know you could do it with 1.0 but I forgot where the files are. ...

What is the best way to store WMD input/markdown in SQL server and display later?

I'm looking at using WMD in my project instead of my existing RadEditor. I have been reading a few posts on how to store and retrieve the data, and I want to make sure I have the concept correct before proceeding. If my research is correct, here is what I should be doing. I should store the editor data twice (Once as HTML and once as...

OutOfMemoryException C# When Uploading Image Files

Hi All, I have been working on an image gallary. When the user uploads an Image I now check the size of the file. If it is less than 1MB I check to see that the file is actually an image type. Finally I resize the image to an appropriate gallary size, and create a small thumbnail of the image. However since adding in the code to check t...

How can I decorate my ASP.NET MVC ViewModel property to render as a textarea when using EditorForModel()

Title says it all... How can I decorate my ASP.NET MVC ViewModel property to render as a textarea when using EditorForModel() ...

ASP.NET MVC - GET with one ViewModel, POST with another.

I'm kind of a noob so please forgive me if this is a dumb question. I am loading a page successfully using Model Binding in ASP.NET MVC 2. Now I want to use Model Binding to submit the results of a form, but I want to use a different Model that the one I loaded with. Is this possible? Or should I just use the same ViewModel for both ...

Using HttpContext.Current.Application to store simple data

I want to store a small list of a simple object (containing three strings) in my ASP.NET MVC application. The list is loaded from the database and it is updated rarely by editing some values in the site's admin area. I'm thinking of using HttpContext.Current.Application to store it. This way I can load it in the Global.asax: protec...

How do I implement rate limiting in an ASP.NET MVC site?

I'm building an ASP.NET MVC site where I want to limit how often authenticated users can use some functions of the site. Although I understand how rate-limiting works fundamentally, I can't visualize how to implement it programatically without creating a major code smell. Can you point me towards a simple yet powerful solution for appr...

Pass Two Values to a View

OK, I'm pretty sure I know the answer to this but just in case. I know I can pass in a composite class to a view / partial view. My question though is can I pass in an object without first having a model. So something like Html.RenderPartial("MyPartialView", new { id=10, name="slappy" }); If I can, what would the partial view look li...

After using Automapper to map a ViewModel how and what should I test?

I am attempting to test the Index action of a controller. The action uses AutoMapper to map a domain Customer object to a view model TestCustomerForm. While this works I am concerned about the best way to test the results that I am receiving from the Index action. The controller's index action looks like this: public ActionResult Index...

Storing Log info using log4net

How to store log in MySql database using log4net ...

How to map table records to Any type using Castle ActiveRecord

I know it's possible to create Any relationships where the related record could be of any type. Is there a way to tell the ActiveRecord the records in a table belong to many different types even when there is no relationships? For example I have a table in which there is a string field that stores the type of each record in table. I'd l...

Deploy asp.net mvc 2 IIS 7.5 with Visual studio 8 and windows 7 pro

I've got problems when I deployed my mvc website with IIS 7.5. On my solution in VS 2008, I published web to an specified folder. Then I go IIS version 7.5 create a virtual directory to my published folder then convert it to web application. When I run it http://localhost/myMVC my flash can't specified file , when I type http://local...

ModelBinder fails with EditorTemplates

Hi! I'm using a ViewModel and EditorTemplates to build up a specific view. Customer is a Linq-2-sql generated object and Customer.Client is a simple string. This: <%= Html.EditorFor(x => x.Customer.Client) %> renders to: <input id="Customer.Url" name="Customer.Url" type="text" value="http://www.golang.com" /> The recieving actio...

When should i go for "spring.net" in asp.net?

When should i go for spring.net framework in asp.net mvc web application? A simple example which could explain its usage in a web application... Any suggestion.. EDIT: Why spring is used? What is the use of it? ...

How do I dispose my filestream when implementing a file download in ASP.NET?

I have a class DocumentGenerator which wraps a MemoryStream. So I have implemented IDisposable on the class. I can't see how/where I can possibly dispose it though. This is my current code, which performs a file download in MVC: using (DocumentGenerator dg = DocumentGenerator.OpenTemplate(path)) { /* some document manipulation wit...