asp.net-mvc

ASP.NET Authenticate Using [Authorize]

I defined a Controller to force authentication by using the [Authorize] attribute. When a session times out, the request is still passed down and executed instead of forcing a redirect. I do use FormsAuthentication to login and logoff users. Any ideas on how to control that? Example: [Authorize] public class ProjectsController : Con...

Forms in MasterPage and Views

I have a master page which all my views inherit from. The issue I am having is with the form tag which is created in the master page and then the form tag which is created in view. Because of the form being inside the master page form, all my postbacks are sent to the controllers Index method and its forcing me to create a new method In...

Live examples of asp.net mvc driven sites / applications

We all know SO is a great solid example of a scalable site/application written in asp.net mvc. Are there any other 'live' examples I can use to pursuade clients this is the route they should be looking at for future developments and allowing their developers time to explore and learn. ...

SmtpClient class not picking up default parameters from Web.Config file.

config file : <system.net> <mailSettings> <smtp from="[email protected]"> <network host="mail.xxxxxx.com" port="25" password="password" userName="[email protected]" defaultCredentials="false" /> </smtp> </mailSettings> </system.net> I've already tried defaultCredentials="true" but i recieved following message: System.FormatException: Sm...

In ASP.NET MVC, how do I get the mangled name of a control when a form is submitted?

I've got a form inside an <asp:Content> block that is being submitted to a controller. For one of the controls, I need to get some information from it directly that won't happen automatically by calling UpdateModel(). However, in the Request.Form dictionary, the control's id is of the mangled form ctl00$ContentPlaceHolder${name}. Given...

Can you enable [Authorize] for controller but disable it for a single action?

I would like to use [Authorize] for every action in my admin controller except the Login action. [Authorize (Roles = "Administrator")] public class AdminController : Controller { // what can I place here to disable authorize? public ActionResult Login() { return View(); } } ...

How do I find out the name of the current controller/action/view?

I have some code that I am putting in the code-behind of a master page. This master page is my main layout and the purpose of the code is to check whether the user is logged in and take the appropriate action depending on whether they are or not. I would be interested in hearing alternate methods on how to approach this, but I am doing i...

How to setup 2 actions with the same name, 1 Authorized and 1 not Authorized?

Is it possble to have something like this in ASP.NET MVC... [Authorize] [AcceptVerbs(HttpVerbs.Get)] public string AddData(string Issues, string LabelGUID) { return "Authorized"; } [AcceptVerbs(HttpVerbs.Get)] public string AddData() { return "Not Authorized"; } So if the user is not logged in, it defaults to the un-Authorize...

Dynamic ASP.NET MVC Routes

I have a requirement to dynamically change a ASP.NET MVC route depending on the contents of the URL. For example: routes.MapRoute( "Default", "{controller}/{action}/{id}/{value}", new { controller = "Home", action = "Index", id = 0, value = "" } ); I'd like to use the above route for most scenarios but also allow {controller}/{...

ASP.NET MVC Authorization

How do I achieve authorization with MVC asp.net? ...

What's the deal with ASP.NET 3.5 Extensions Preview 2?

I'm trying to get the MVCToolkit working with an ASP.NET MVC Beta application and ran into an unresolved reference to System.Web.Extensions version 3.6 (ASP.NET MVC Beta comes with System.Web.Extensions version 3.5). All my google searches seem to point to a broken download link on Microsoft's site: ASP.NET 3.5 Extensions Preview 2 ...

Form Submits same checkbox values on subsequent submit action in MVC

I have followed the suggestion in this question... [http://stackoverflow.com/questions/220020/how-to-handle-checkboxes-in-aspnet-mvc-forms][1] ...to setup multiple checkboxes with the same name="..." attribute and the form behaves as expected the FIRST time its submitted. Subsequent submissions of the form use the original array of Gu...

Anyone know whether there is a 5-star rating control for asp.net mvc?

I require a star rating control (which allows partial rating like 4.5) for my application built on asp.net mvc. Any pointers in this direction will be helpful? ...

How can I make a user control's form portable to other pages

I have a user control that will be used in several pages (as is the custom with user controls) that contains a form. I was thinking on how to guarantee its functionality. First I wanted to have a single controller with a single method accept the values for this form. The only thing blocking me there is that after this method is done wit...

Server Error in '/' Application. No parameterless constructor defined for this object.

The callstack shows the following: [MissingMethodException: No parameterless constructor defined for this object.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean p...

Which action is executing during an HtmlHelper extension method

I'm working on a menu-generating HtmlHelper extension method. This method will need to know which Action is being executed. So if Home/Index is executing, the extension method would show all links to other actions that're "coordinated." In a sense, all I need to know during the execution of the Home controller's Index action is the name ...

How do I Unit Test Actions without Mocking that use UpdateModel?

I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC Beta 1. In it he shows the improvements made to the UpdateModel method and how they improve unit testing. I have recreated a similar project however anytime I run a UnitTest that contains a call to UpdateModel I receive an ArgumentNullException naming the ...

what wrong with this linq to sql

i get this error {"Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL."} when i try to execute this linq to sql var query = from p in db.Posts let categories = GetCategoriesByPostId(p.PostId) let comments = GetCommentsByPostId(p.PostId) ...

MVC Javascript error

I have configured my default page to be say "abcd.aspx" and is under ~/View//abcd.aspx and I have my javascripts under ~/Contents/Scripts/.js For some reason, only "../Content/Scripts/.js" works for including the js file on the page and "~/Contents/Scripts/.js" does not. This works only when i access the page with the full url: http:///...

ASP.NET MVC: How to Route Search Term with . (Period) at the end

I get a 404 response from .Net MVC when I try to make a request where my search term ends with a . (period). This is the route that I'm using: routes.MapRoute( "Json", "Remote.mvc/{action}/{searchTerm}/{count}", new { controller="Remote", count=10} ); The search works fine wi...