asp.net-mvc

Why can't I use an iteration variable in a LoginView?

I am building a .NET MVC app that has a page with a list of delete buttons, one for each item in a list. The problem I'm having is that the foreach variable "item" is not visible inside the LoginView, which results in the following error: Compiler Error Message: CS0103: The name 'item' does not exist in the current context Below is a s...

ASP.NET MVC + SQL Server Application: Best Way to Send Out Event-Driven E-mail Notifications

I have an ASP.NET MVC application that utilizes NHiberante and SQL Server 2008 on the backend. There are requirements for sending out both event-driven notifications on a daily/weekly basis AND general notifications on a weekly basis. Here is an example of how the event-driven workflow needs to work: Employee(s) create a number of pu...

How do I mock the HttpContext in ASP.NET MVC using MOQ?

[TestMethod] public void Home_Message_Display_Unknown_User_when_coockie_does_not_exist() { var context = new Mock<HttpContextBase>(); var request = new Mock<HttpRequestBase>(); context .Setup(c => c.Request) .Returns(request.Object); HomeController controller = new HomeC...

How do I convert an HttpRequestBase into an HttpRequest object?

Hi folks, inside my ASP.NET MVC controller, I've got a method that requires an HttpRequest object. All I have access to is an HttpRequestBase object. Is there anyway I can somehow convert this? What can/should I do?? ...

Why don't the HTML helpers output anything in this ASP MVC view?

Below is my asp mvc view. Note that it has a div which contains a simple form. I am using Html.TextBox() to try to output input elements but nothing is output. The form renders properly but where I expect to see the input tag there is nothing. I'm sure this is a total beginner mistake but what am I doing wrong? <%@ Page Language="C#...

How to trigger Initialize method while trying to Unit Test?

I have the override below to do a few things with cookies using the FormsIdentity Object. But when I instantiate a controller on my Unit Testing this method is not triggered. Any ideas how to do this? protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); ...

How can I speed up my pagination code in ASP.NET MVC with Azure?

I'm using ASP.NET MVC and Azure Table Storage in the local development fabric. My pagination code is very slow when working with a large resultset: var PageSize = 25; var qResult2 = from c in svc.CreateQuery<SampleEntity>(sampleTableName) where c.PartitionKey == "samplestring" selec...

Is there a good/proper way of solving the dependency injection loop problem in the ASP.NET MVC ContactsManager tutorial?

If you don't know what I'm talking about either go through the tutorial and try to add dependency Injection yourself or try your luck with my explanation of the problem. Note: This problem isn't within the scope of the original tutorial on ASP.NET. The tutorial only suggests that the patterns used are dependency injection friendly. The...

ASP.Net MVC partial views

I have a menu (jquery-ui accordion with Html.ActionLink as menu options). How can I render a partial view in the main content <div> of the parent view, when selecting a menu option? I can render the partial view, but not inside the main content <div>. Should I use Html.ActionLink in my menu options? ...

Is Enabling Double Escaping Dangerous?

I have an ASP.NET MVC application with a route that allows searching for stuff via /search/<searchterm>. When I supply "search/abc" it works well, but when I supply "/search/a+b+c" (correctly url encoded) then IIS7 rejects the request with HTTP Error 404.11 (The request filtering module is configured to deny a request that contains a d...

permissions aware (icon) action links for all models: how?

I have several models, for which I want to show some common icons for action links (new, details, edit, delete) and some specific ones for certain models only; these iconlinks must only be showed when the user has permission to perform the action. Permissions are decided by roles, but I'd like to abstract them, so that the explicit neede...

asp.net mvc captcha

im looking for a captcha control that is designed for asp.net mvc which one is the easiest to implement? ...

How to Bypass HTTPContext Usage .?

var mockedService = new Mock(); mockedService.Setup(x => x.InterfaceMethod(args)).Returns(value); _Service = mockedService.Object; MyController controller =new MyController(_Service); var result = (ViewResult)controller.Foo(); Now this Foo() Method contains the Following API Call HttpContext.GetGlobalResourceObject(...,...

My custom ASP.NET MVC entity binding: is it a good solution?

Suppose I want to allow to select our entity (from a dropdown, etc) on a page, let's say Product. As a result I may receive this: public ActionResult SelectedAction(Guid productId) { } But, I want to use model binders power, so instead I write model binder to get my product from repository and instead use public ActionResult Selected...

ASP.NET MVC Login Modal Dialog/lightbox

I was hoping to create a lightbox/modal dialog for login into my website which is built with asp.net mvc. However the only way i can think of is to put logic into the onClick events for the hyperlinks when linking to restricted sections. I would prefer it so I could still use the Authrisation action filter, and when you click on a link t...

asp.net mvc with optional parameters and partial views

i have: AlbumsController PhotoRepository Index.aspx (view) inside of Index.aspx, i have a partial view call AlbumControl. I want to update this via ajax and ajaxhelper. the issue is that i want the ability to do the following: http://www.mysite.com/Albums http://www.mysite.com/Albums?FilterTag=Birthdays when i do this, i get the fo...

Where is the eroneous "Id" coming from?

I'm experimenting with the MVC beta 2 and have the following method in a controller: [HttpPost] public ActionResult Create(Issue issue) { if(TryUpdateModel(issue, "Model", new [] {"Title", "Description"})) { ServiceCaller.PutIssue(issue); return RedirectToAction("Index"); } return RedirectToAction("Create"); ...

ASP.Net MVC partial views and jqGrid

I get the following error message when rendering a partial view with a jGrid on. "Microsoft JScript runtime error: '$.jgrid.defaults' is null or not an object" I have included the relevant .js files. I am concerned about the following line in jquery.jqGrid.js var pathtojsfiles = "/Scripts/"; All my .js files are under the scripts fo...

MVC menu that will also work with ASP WebForms

We have been happily using the ASPExpert Menu control at work. Recently I have received the green light to update a portion of the site to use MVC. In doing so, I have to maintain the look and feel of the existing site on to the newer MVC portion of the site... This includes the menu. Unfortunately, it looks like ASPExpert Menu is de...

Print Data to screen based off of a query in ASP.NET MVC?

I have an application I'm working on where I want to loop through some data where a flag in the data is set to 1 or 2 and print it to screen. The idea I'm working on using is from one of the MVC tutorials: <ul> <% For Each m As Movie In ViewData.Model%> <li><%= m.Title %></li> <% Next%> </ul> But I want to do similar to the abo...