asp.net-mvc

Set authentication as true for the view of the control that performs the authentication in ASP.Net MVC

In the authentication control I have the following line to mark a user as authenticated in the system (after checking out the password): FormsAuth.SignIn(userName, rememberMe); and if I redirect, which is the standard behvaior, everything is ok. But if I show a view right away, the usual ways to check whether a user is authenticated: ...

ASP.NET MVC Authorize Attribute - NOT WORKING!!!

Hey guys, I'm a bit frustrated here. I'm not quite sure what's going on. I started with the default MVC Project Template and proceeded to add a Controller ... public class TestTemplatesController : EVController<EvTestTemplate> { // // GET: /Tests/ [Authorize] public ActionResult Index() { ViewData.Model = E...

How do I support ETags in ASP.NET MVC?

How do I support ETags in ASP.NET MVC? ...

Correct way to reference Javascript in ASP.NET MVC?

What is the correct way to reference Javascript in ASP.NET MVC? Using something like ../../Scripts/Myscript.js seems to work fine for routes that are the traditional {controller}/{action}/{id}, but are more fragile for anything more or less complex than that. Of greater concern is that the rational absolute reference (/Scripts/Myscript.j...

Adding references to ASP MVC Page Compilation Engine

Hello, I have written a plugin solution for ASP MVC applications based on the advice found on this site, however, I have reached a roadblock and would appreciate some help. Without going too deep into how the plug-in system works, it does successfully load the controller and finds its appropriate view - the problem is that the view does...

How do I make a "back" link?

I have a detail page that gets called from various places and has a nice readable url like "www.mypage.com/product/best-product-ever". The calling pages (list of products) have a more complex url like: "www.mypage.com/offers/category/electronic/page/1/filter/manufacturer/sony/sort/price" and "www.mypage.com/bestseller/this-week". H...

Create custom tag

In my views I verry often have to write <%=Model.T9n.TranslateById("someId");%> Is there some way to make this more compact/readable. A custom tag maybe? <asp:T9n>someId</asp:T9n> or better <t9n: someId /> Note There are several (business) reasons why I can't use the default T9n tools in visual studio so that's why I've rolled ...

How to make menu by using Master Page with jquery?

Hi guys nowadays i m making one mvc project and i use master page i wanna make menu with items have active preferences i used $(document).ready(function() { //document $('#tabMenu > li').click(function() { //clik if (!$(this).hasClass('active')) { //if $('#tabMenu > li').removeClass...

Clear Request.IsAuthenticated value after SignOut() without RedirectToAction()

I am writing an account management controller and have to process deleting of own user's account separately: [Authorize] [AcceptVerbs(HttpVerbs.Post)] public ActionResult Delete(string userName, string confirmButton) { MembershipService.DeleteUser(userName); if (User.Identity.Name.Equals(userName, StringComparison.Invar...

Open pdf in browser plugin

Hi How do I (in my controller) send a pdf that opens in the browser. I have tried this but it only downloads the file (both ie and firefox) without asking. public ActionResult GetIt() { var filename = @"C:\path\to\pdf\test.pdf"; // Edit start ControllerContext.HttpContext.Response.AddHeader("Content-Disposition", String.For...

Justification for MVC?

Hi guys, I was wondering if someone could provide me with some answers. I've been asking to swap our internal apps to an MVC architecture for quite a while now. Rails was absolutely shot-down as a toy, Struts is just too huge for the apps we do, Django's name makes these old folks nervous (oil & gas industry) but finally, finally Micr...

How do I assign a Role to an OpenId user for an ASP.NET MVC site?

Hi Folks, I'm using OpenId in my ASP.NET MVC application. Works great :) Once i have the user's OpenId Identifier (once they have authenticated and returned to my site), i load up the users data (to get display name, etc). From here, i also know their roles. I'm not sure how to assign the role to the current Forms.Identity. here's my...

MVC - Fill DropDownList from 2 Tables

I would Like to Know How I could Fill A DropDownList from 2 Tables. I have Tables: Categories Subcategories I should look like this: -- Vehichles -- //From Categories Cars //From SubCategories Bikes -- Houses -- Vila Aparatment This tables are conected to eachother with foregin keys. and I use Linq to SQL. Any Good So...

How to configure ELMAH to work with Windows Azure? I get a 404 on Elmah.axd.

I have an ASP.NET MVC web role running on Windows Azure and have setup ELMAH properly in the web.config. I also have my global.asax ignore *.axd routes. Locally, I am able to load /elmah.axd, however when I deploy to Azure, I get a 404 on that page. Has anyone gotten ELMAH working on Azure? ...

What is this RenderAction doing, and how?

I am reviewing some ASP.NET MVC code developed by a third party and have encountered the following markup in a View: <div class="panel_body"> <% Html.RenderAction(((string[])Model)[0], "Customer"); %> </div> <!-- Some HTML omitted --> <div class="wizard_body"> <% Html.RenderAction(((string[])Model)[0], "Journey"); %> </div> ...

Trim() FormCollection values

Hi I'm fooling around with the NerdDinner tutorial Dinner Edit control. I get a FormCollection as one of the arguments, can I trim the data in it before I use UpdateModel(). [AcceptVerbs(HttpVerbs.Post)] public ActionResult Edit(int id, FormCollection formValues) { Dinner dinner = dinnerRepository.GetDinner(id); ...

How to allow users to modify front end menus?

I am writing a backend/admin area for a website. The users want the ability to modify their menu's on the website. These menus can be heirachical no more than 3 levels deep. Do you allow users to do this? How do you store the heirarchy? How do you programmatically display the menu? How do you make it easy for users to create heirar...

Surrounding a ValidationSummary with a box via CSS

Hi, By default Html.ValidationSummary() produces HTML like this: <span class="validation-summary-errors">There were some errors...</span> <ul class="validation-summary-errors"> <li>First Name too long</li> <li>Invalid Email Address</li> </ul> I'd like to select the entire validation summary and add a bounding box around it via ...

ASP.NET MVC Debugging Very Slow - SQL Server Express Connection Issue?

I am developing an application in ASP.NET MVC, using SQL Server Express as the backend and Cassini as the development web server (the one that comes with Visual Studio 2008). The application performance is blazingly fast (nearly instantaneous page switches). However, spinning up the debugger is painfully slow; it takes about 30 seconds...

ELMAH vs Enterprise Library Exception Handling Block

My team is currently in the process of building an ASP.NET MVC application, and we're trying to decide which of these frameworks to implement to deal with error handling and logging. What are the reasons for choosing one of these over the other? ...