asp.net-mvc

Changing User in MVC 2 MockHttpContext breaks Test?

I changed the following line: private readonly IPrincipal _user = new GenericPrincipal(new GenericIdentity("someUser"), null /* roles */); to private readonly IPrincipal _user = new GenericPrincipal(new GenericIdentity("realUser"), null /* roles */); and the following test broke, but I am not sure why and I am not ...

how to save html to a database field

i have an tiny editor web page where my users can use this editor and i am saving the html into my database. i am having issues saving this html to my database. for example if there is a name with a "'" or if there are other html character "<,",">" etc, my code seems to blow up on the insert. Is there any best practices about taking an...

How to return all aspnet_compiler errors (not just those in first directory)

Hi there! Is there a way to get the aspnet_compiler to go through all views and return all errors, rather than just the errors in the current view directory? For example, lets say I have a project that has a bunch of folders... Views Folder1 Folder2 Folder3 Folder4 Two of them (Folder2 and Folder3) have errors. aspnet_compiler wi...

How should I unit test sending email from a controller?

I'm getting started with unit testing and trying to do some TDD. I've read a fair bit about the subject and written a few tests. I just want to know if the following is the right approach. I want to add the usual "contact us" facility on my web site. You know the thing, the user fills out a form with their email address, enters a brief...

Unit Test Sessions Window Closes when debugging

When I select an NUnit test in the Unit Test Sessions window and click debug, the window disappears. My breakpoints are hit, but if I hit F5, the Unit Test Sessions window does not return until the test returns a result or I stop the debugging session. This is preventing me from viewing any console output during tests. Any ideas? ...

Dictionary to Json object, "Expected expression"

I'm trying to convert a dictionery into a json object, so that I can work with it in my front end. sortFields = <%= SchrodersHtmlHelper.ToJson(ViewData["SortInfo"])%>; However, I keep on getting "Expected expression" for this all the time and I'm clueless why. Could anyone explain to me what I'm doing wrong? Edit: The conversion wor...

why do i need to do html.encode()

if i have a user entering data into a rich text editor (tiny editor) and submitting data that i am storing into a database and then retrieving to show on other dynamic web pages, why do i need encoding here. Is the only reason because someone might paste javascript into the rich text editor? is there any other reason ? ...

Simple ASP.NET MVC Routing question

Hi there, I have two pages in my simple MVC App with two defined routes: routes.MapRoute( "Results", // Route name "Results/{id}", // URL with parameters new { controller = "Results", action = "Index", id = "" } // Parameter defaults ); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}",...

Is it possible to use Html.RenderPartial in non-MVC ASP.Net page?

I want to render MVC controls in non-MVC ASP.Net pages. Is this possible? ...

Should you use storeded procedures in linq to sql?

Does someone out there use stored procedures with linq to sql and why? Should we use them? Their support is there in linq to sql. I am asking because I use to use it before my recent application. ...

ASP.NET MVC Deployed Application Server Address

I have an application that sends an email to a user so that they may access a web form. In the email there is just a link to the start page of this form. Currently, I have the value for the form location hardcoded. Once the app is deployed I know it is in inetpub/wwwroot/appName, which results in a URL of serverip:appPort/appName. What ...

Sort on amount of likes on facebook

I have a site with a bunch of links, the page is also connected to facebook (facebook connect) and you can "like" the links. I wonder if there is a way to sort on the "most liked" link? The links are stored in my database and of course the liking is stored by Facebook... ...

Asp.Net Program Architecture

I've just taken on a new Asp.Net MVC application and after opening it up I find the following, [Project].Web [Project].Models [Project].BLL [Project].DAL Now, something thats become clear is that there is the data has to do a hell of a lot before it makes it to the View (Database>DAL>Repo>BLL>ConvertToModel>Controller>View). The DA...

Playing flash video with ASP.NET MVC

What's a good flash player to use on an ASP.NET MVC site? The page I'm working on will need to display a number of videos on each page dynamically based on what the user searched for. I'd like each of the videos to show up as thumbnails that can be played, paused, and or enlarged to full screen. I've worked with the standard ASP.NET an...

ASP.NET MVC PartialView generic ModelView

I have an ASP.NET MVC application which I want to dynamically pick the partial view and what data gets passed to it, while maintaining strong types. So, in the main form, I want a class that has a view model that contains a generically typed property which should contain the data for the partial view's view model. public class MainView...

Why did the aspnet_client folder come back in ASP.NET 4?

I recently upgraded my MVC 1 project (ASP.NET 3.5) to MVC 2 (ASP.NET 4). I noticed there is now a folder "aspnet_client\system_web\4_0_30319" under the site root. This folder is empty... I'm just wondering if anyone knows why it was created. I remember the aspnet_client folder from the days of .NET 1.1, but I thought it was obsoleted wh...

How to stream audio from ASP.NET MVC controller when it's still encoding?

Background I have wave files on my server that I want to stream. Because of the size I want to encode them to mp3. I've tried to use FileStreamResult - but it doesn't work because as soon as program leaves the controller stream is closed and I get - "Cannot access a closed stream" FileContentResult - but it's not a stream and the u...

Why is this giving me 2 different sets of timezones?

Edit I believe this is a issue with I am using windows 7 and my server is windows 2008. I think windows 2008 uses still GMT. So how could I get around this issue. Like I want to deal in UTC but I want to have the default selected item to be "Coordinated Universal Time" what is not in the gmt list but in the UTC list. So I am not sure ...

ASP.NET Web Site Administration Tool unkown Error ASP.NET 4 VS 2010

I was following the MVCMusic tutorial with an machine with full sql server 2008 r2 and full visual studio professional, in ASP.NET 4.0 and when I got to the page where it sets up membership (near page 66) the Web administration tool wont work, i got the following error: An error was encountered. Please return to the previous page and tr...

Email as a view.

I've been in some discussion recently about where email (notifications, etc...) should be sent in an ASP.NET MVC application. My nemesis grin argues that it only makes sense that the email should be sent from the controller. I argue that an email is simply an alternate or augmented view through a different channel. Much like I would dow...