asp.net-mvc

How to obtain email address with window authentication.

I am designing a web application using the ASP.net MVC framework. I would like to use Windows Authentication and do Role Checks using the Role Manager SQLRoleProvider. How can I determine the email address of the current logged on user? Is this even possible? The application will be deployed in a multi-domain intranet, if that matt...

How to get "Host:" header from HttpContext (asp.net)

I need to server parts of my application from different domains. To be precise I have a sub section of the site that should be served from a region specific domain. For example: /fr/* should be served from www.domain.fr /uk/* should be serverd from www.domain.co.uk and so on. I'd like to make a route entry that will redirect the requ...

Multiple skins in ASP.NET MVC using StringTemplate

I am considering the StringTemplate view engine for my ASP.NET MVC application. This application will be built with one skin, but I then expect many more, often very similar skins to be developed for it. This is primiarly the reason for my choice of StringTemplate as the view engine, as there will be zero logic in the views. In my head,...

asp.net mvc Html.Textbox, unable to set value?

in my route table I have this entry routes.MapRoute( "myRoute", "route/{controller}/{action}/{id}/{start}/{end}", new { controller = "Home", action = "Index", id = "", start="", end="" } ); in my master page I have a line of code like so: <%= Html.TextBox("foo", "bar") %> If I access the ...

What is the simplest way to return different content types based on the extension in the URL?

I'd like to be able to change the extension of a url and recieve the model in a different format. e.g. if /products/list returns a html page containing a list of products, then /products/list.json would return them in a json list. Note: I like the simplicity of the ASP.NET MVC REST SDK, it only requires about 5 lines of code to hoo...

ASP.NET MVC Ajax: How to pass argument values to Ajax action from a select?

I would like to have filtering page that performs ajax requests to asynchronously update list of results. There are two comboboxes with option values and one Ajax.ActionLink. The list is rendered as a partial view inside a div. I know how to implement the controller part and also the interaction logic. What I am missing is how to pass ...

ASP.NET MVC RequireHttps in Production Only

I want to use the RequireHttpsAttribute to prevent unsecured HTTP requests from being sent to an action method. C# [RequireHttps] //apply to all actions in controller public class SomeController { [RequireHttps] //apply to this action only public ActionResult SomeAction() { ... } } VB <RequireHttps()> _ Publ...

Asp.net mvc Parent/Child Create/Update View

What is the best practice for creating/updating the data using the following pseudo view: parent name field parent description field table with child data: existing fields fields for child[1] with existing data fields for child[2] with existing data empty field[1] for a new child [add new child button (just creates ...

MVC 2 AreaRegistration Routes Order

I noticed that in MVC 2 Preview 2, AreaRegistration is loading the routes for each area in an arbitrary order. Is there a good way to get one before the other? For example, I have two areas - "Site" and "Admin". Both have a "Blog" controller. I would like the following: /admin/ --> go to Admin's Blog controller / --> go to Site...

Customize HtmlHelper.ValidationMessage output

Is it possible (and how) to customize the HTML output of the HtmlHelper.ValidationMessage extension method in Asp.net MVC? ...

.NET MVC custom routing with empty parameters

Hi All, I have a .net mvc with the following routes: routes.Add(new Route( "Lookups/{searchtype}/{inputtype}/{firstname}/{middlename}/{lastname}/{city}/{state}/{address}", new RouteValueDictionary( new { controller = "Lookups", action = "Search", firstname = (string)null, middlename = (string)null, lastname = (...

Determining which checkboxes are not checked in ASP.NET MVC?

Imagine a page which uses checkboxes to keep track of mailing list subscriptions about pets: cats-list ( ) dogs-list (*) birds-list ( ) horses-list (*) I use ASP.NET MVC's Html.Checkbox extension method in a loop (not shown): <%= Html.Checkbox("subscriptions[" + i +"]", item.subscribed, item.listName) %> "i" is the iteration variab...

ASP.NET MVC Response Filter + OutputCache Attribute

I'm not sure if this is an ASP.NET MVC specific thing or ASP.NET in general but here's what's happening. I have an action filter that removes whitespace by the use of a response filter: public class StripWhitespaceAttribute : ActionFilterAttribute { public StripWhitespaceAttribute () { } public override void OnResultExecuted(Resul...

Reference problems when using VirtualPathProvider to dynamically load a view

I have the following set of classes that I used to dynamically load in a View. The code below works well when called with .RenderPartial. public class VirtFile:VirtualFile { public VirtFile(string virtualPath) : base(virtualPath) { } public override Stream Open() { string path = this.VirtualPath; S...

Implementing custom login for ASP.NET MVC

Hi, I'm new to ASP.NET MVC and need abit of advice on how to implement the following. The site is a heavily used site with roughly 200 users internally (intranet). We use forms authentication hitting a SQL Server DB (not windows integrated). Some actions are protected, some are viewable by anyone and some are viewable by both - so if...

Issue with ASP.NET MVC model binder

With this controller method: - [AcceptVerbs(HttpVerbs.Post)] public ViewResult Contact(Contact contactMessage) { return View(); } Why does this work... public class Contact { public string Name { get; set; } public string Email { get; set; } public string Message { get; set; } } <% using(Html.Begi...

ASP.NET MVC - XVal clientside validation of dates

I'm having some problems with xVal's clientside validation when it comes to dates. I can't get it to work with a swedish date format which is yyyy-mm-dd, it only seems to work with mm/dd/yyyy. Is there a way to make it work with other date formats? ...

Moq Mocking and tracking Session values

I'm having problems returning a Session value set from mocking using Moq. Using the following public class TestHelpers { public long sessionValue = -1; public HttpContextBase FakeHttpContext() { var httpContext = new Mock<HttpContextBase>(); var session = new Mock<HttpSessionStateBase>(); httpContext.Setup(x => x.Session).Retu...

asp.net ( mvc ) using external folder as resource

Hi, i've got a VS2008 asp.net mvc solution with the projects: Common Project_1 Project_2 The common project also contains an "images" folder with "common images" that should be used by both of the 2 projects... How would i "link" to these folder from one of the projects now, when it should be available via a browser ( e.g. via a pa...

How to pass two sets of data to a view?

How do I go about passing two sets of Data to a view in ASP.NET MVC? I've tried a couple of things and neither have worked so I've come to the simple conclusion: I'm doing it wrong. I have 2 queries: callRepository.FindOpenCalls() and callRepository.FindAllMyCalls(user) and I want to out put both sets of data to one view via 2 partia...