asp.net-mvc

Using Structuremap to manage ObjectContext Lifetime in ASP.NET MVC

Hi, what I want to know If there is a way or an good article on how to manage the objectcontext life cycle through structuremap (I saw an example with ninject). Since I'm new to the methods and possibilities of SM I really don't know How/If possible to make it. In the first moment I wanted to make a singleton of the objectcontext per htt...

MVC using the same partial view twice in the same view

I have a strongly typed partial view named "Adress". This partial view contains 'input' fields associated to an Adress model class. I want to render it twice in the same view because the user must input the business adress and the delivery adress. I have problem with client validation because of the ID of the 'input' rendered is not un...

UrlRewriting from ASP.NET WebApplication to ASP.NET MVC WebApplication

Hello, I have an ASP.NET Web Forms Application in migration process to ASP.NET MVC 1. Urls are as follows: hxxp://domain/Default.aspx (WebForms) hxxp://domain/mvc/Controller/Action (MVC) (hxxp because stackoverflow thinks they are links and prevents me from posting so many) "mvc" is another application inside my Web Site in IIS7. I ...

Url does not change in display when redirecting

action: User/Details View: Details In my 'Details' view, a user can click on an actionlink that goes to the action :User/UserBehavior From which I again return a "Details" View. the url shows http://User/UserBehavior If I return redirectToAction to the Details action, I still get the "UserBehavior" action in the url. how do I redi...

ASP.NET MVC2 and MemberShipProvider: How well do they go together?

I have an existing ASP.NET application with lots of users and a large database. Now I want to have it in MVC 2. I do not want to migrate, I do it more or less from scratch. The database I want to keep and not touch too much. I already have my database tables and I also want to keep my LINQ to SQL-Layer. I didn't use a MembershipProvider...

Client Id for Property (ASP.Net MVC)

Hi guys... I'm begginer in asp.net mvc, and i have a doubs: I'm trying to do a label for a TextBox in my View and I'd like to know, how can I take a Id that will be render in client to generete scripts... for example: <label for="<%=x.Name.?ClientId?%>"> Name: </label> <%=Html.TextBoxFor(x=>x.Name) %> What need I put in "?ClientId?"...

ASP.NET MVC2: Can you get ModelMetadata.ContainerType from within a collection?

I'm trying to call DisplayFor and DisplayForModel to iterate an IEnumerable<> with various element types from within a view. I have Templates defined for each element/Model type. What I would like to do is check the ViewData.ModelMetadata.ContainerType from within the Template so that Template can determine if it was called as part of a...

Show loading image when pdf rendering

I am displaying pdf on my page like this <object data="/Customer/GetPricedMaterialPDF?projID=<%= ViewData["ProjectID"]%>" type="application/pdf" width="960" height="900" style="margin-top: -33px;"> <p> It appears you don't have a PDF plugin for this browser. No biggie... you can <a href="/Customer/GetPricedMa...

Custom Validation Attribute with Custom Model Binder in MVC 2

I apologise for the amount of code I have included. I've tried to keep it to a minimum. I'm trying to have a Custom Validator Attribute on my model as well as a Custom Model binder. The Attribute and the Binder work great seperately but if I have both, then the Validation Attribute no longer works. Here is my code snipped for readabi...

Why Date Format in ASP NET MVC Differs when used inside Html Helper?

Hi, I just came across a very interesting issue. If I use ViewData to pass a DateTime value to the view and then display it inside a textbox, even though I'm using String.Format in the exact same manner, I get different formatting results when using the Html.TextBox helper. <%= Html.TextBox("datefilter", String.Format("{0:d}", ViewData...

MVC Helper Extension issue

I need to implement a HtmlHelper extension in my MVC project simply just to output some string but ONLY in the DEBUG mode, not in RELEASE. My first attempt would be: [Conditional("DEBUG")] public static string TestStringForDebugOnly(this HtmlHelper helper, string testString) { return testString; } But obviously that would give a c...

User is not able to log in after some time

I am using asp.net mvc along with SQL server. An user of my application created a username like "abcd efgh", with space between the user name. it worked for some time and now it stopped working. I checked that user is entering the correct data. This happened even user did not have a space in it. I set up the membership database using Asp...

Problem with Deploying a ASP.NET MVC Project on a IIS 7.0. BadImageFormatException

Hello world, I am stuck with my web application. As known from the title its a ASP.NET MVC(1,0) application so i do the only 2 things that a needed do deploy a application like this. I made a build an copied it to the IIS Folder. In the IDE (VS2008) all works fine :(. This worked a long time. But know i get a error for my included dll...

asp.net mvc - How to create fake test objects quickly and efficiently

Hi, I'm currently testing the controller in my mvc app and I'm creating a fake repository for testing. However I seem to be writing more code and spending more time for the fakes than I do on the actual repositories. Is this right? The code I have is as follows: Controller public partial class SomeController : Controller { IRepos...

How to create a reusable Asp.Net Mvc application?

We have multiple Asp.Net WebSites each running on IIS. Site1 : http://www.Site1.com/ Site2 : http://www.Site2.com/ We have to implement Shopping Cart functionality for each of the above WebSites. For each web site the corresponding shopping cart should work on the following Url. Shopping Cart for Site1 : http://www.Site1.com/...

Mocking Ajax.IsRequest to return False

I am trying to mock the Ajax.IsRequest() method of ASP.Net MVC. I found out how to do it in order for it to return true: Expect.Call(_myController.Request.Headers["X-Requested-With"]).Return("XMLHttpRequest").Repeat.Any(); This works and returns true. Now I need to test the other branch of the code. How can I mock it to return false? ...

asp.net mvc How to test controllers correctly

Hi, I'm having difficulty testing controllers. Original my controller for testing looked something like this: SomethingController CreateSomethingController() { var somethingData = FakeSomethingData.CreateFakeData(); var fakeRepository = FakeRepository.Create(); var controller = new SomethingController(fakeRepository); ...

Problem Redirecting From MasterPage in Asp.net mvc

I have a masterpage on which ill check for a condition if condition is true i want to redirect it to a particular view. how can i do this because on masterpage either view() or RedirectToAction() function are available. My condition is if(Session["Name"]==null) //redirect to login else //work as usual ...

How to redirect if javascript is disabled in asp.net mvc masterpage

I have a masterpage on which i want to check if user have disabled its javascript then redirect to a simple error.aspx page ...

close jquery UI dialog when file download begins

I am using an ASP.Net MVC site that has a link to an ASP.Net WebForms page that performs the actual download. I would like my jquery ui dialog to close when the download starts. Is there a javascript/jquery event that I can use to accomplish this? I found an example with exactly what I want to do here, but since I'm using MVC instead of...