asp.net-mvc-2

ASP.NET MVC 2 - How to ignore an entire directory using IgnoreRoute?

让人想犯罪 __ 提交于 2019-12-03 04:58:33
I've tried the following two methods to try and ignore my "Assets" folder, but I keep coming up with errors. Can anyone tell me exactly how the Ignore Regex is supposed to look? routes.IgnoreRoute("/Assets/") routes.IgnoreRoute("{*assets}", New With {.assets = "\/Assets\/(.*)"}) Try routes.RouteExistingFiles = false routes.IgnoreRoute("Assets/{*pathInfo}") Rob Rodi routes.IgnoreRoute("Ignore/"); will prevent the standard The controller for path '/Crap/Home' was not found or does not implement IController. Asp.net mvc exception. 来源: https://stackoverflow.com/questions/3251830/asp-net-mvc-2-how

Read OAuth2.0 Signed_Request Facebook Registration C# MVC

家住魔仙堡 提交于 2019-12-03 04:43:11
My question is very similar this but I guess I need to take it one step further. Facebook says "The data is passed to your application as a signed request. The signed_request parameter is a simple way to make sure that the data you're receiving is the actual data sent by Facebook." After a user has logged into my asp c# MVC site and clicked "Register", the redirect-url is http://site/account/register . At that point (the post to the account/register control), I would like to gather the user's information using the signed request so that I can register them with my site locally. I cannot figure

MVC and EditorFor width

纵饮孤独 提交于 2019-12-03 04:31:27
Can I set the width of an EditorFor control on my View? I have set a few parameters: [Required, DisplayName("Payee Name"), StringLength(50)] public string Name { get; set; } However, I can't seem to set the width of the textbox that gets rendered. <table width="300" border="0" cellpadding="3" cellspacing="0"> <tr> <td> <%=Html.LabelFor(m => m.Name)%> </td> <td> <%=Html.EditorFor(m => m.Name)%> </td> </tr> Can this be done somehow? I tried: <%=Html.EditorFor(m => m.Name, new {width=50)%> But no joy... Instead of EditorFor, use TextBoxFor: <%=Html.TextBoxFor(m => m.Name, new {style = "width:50px

Why really short timeout in ASP.NET MVC?

让人想犯罪 __ 提交于 2019-12-03 04:16:02
问题 I have an MVC 2 application where the timeout is set to 2880 (minutes as I understand it, but even if it is seconds there's a problem): <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> Now this should then mean 48 hours, or at least 48 minutes (if the value is seconds). But the user is logged out after as little as a couple of minutes of inactivity... Why is that? Any help appreciated! 回答1: Found the answer finally after a lot of Googling...

Asp.net MVC Authorize attribute, redirect to custom “no rights” page

浪子不回头ぞ 提交于 2019-12-03 04:14:18
问题 Asp.net MVC2 does redirect to login page with response 302 when authenticated user has no rights. I would like to split into two actions If user is not authenticated then do what it does, redirect to login page. If user is authenticated but has no required rights then return appropriate http status code and show no rights dude page. Is there any way to do it? Or am I doing something wrong with authorize and form authentication? Only way I can think of is by writing custom authorize attribute,

How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default

孤街醉人 提交于 2019-12-03 04:12:32
How can i Set RadioButtonFor() as Checked By Default <%=Html.RadioButtonFor(m => m.Gender,"Male")%> there is way out for (Html.RadioButton) but not for (Html.RadioButtonFor) any Ideas? Mac This question on StackOverflow deals with RadioButtonListFor and the answer addresses your question too. You can set the selected property in the RadioButtonListViewModel. Gabriel Militello Use the simple way: <%= Html.RadioButtonFor(m => m.Gender, "Male", new { Checked = "checked" })%> Adrian Grigore It's not too pretty, but if you have to implement only very few radio buttons for the entire site, something

Are there any non-obvious dangers in using threads in ASP.NET?

筅森魡賤 提交于 2019-12-03 04:07:01
This is something of a sibling question to this programmers question . Briefly, we're looking at pushing some work that's been piggy-backing on user requests into the background "properly." The linked question has given me plenty of ideas should we go the service route, but hasn't really provided any convincing arguments as to why, exactly, we should. I will admit that, to me, the ability to do the moral equivalent of WorkQueue.Push(delegate(object context) { ... }); is really compelling, so if its just a little difficult (rather than inherently unworkable) I'm inclined to go with the

Asp.net Mvc custom mechanism to handle unauthorized request

夙愿已清 提交于 2019-12-03 03:47:20
问题 For my website i want following behaviors for secured controller(or action) if a user makes a normal request redirect to login page (which i have easily able to do) if request is Ajax type Request.IsAjaxRequest()==true , return status code 401 How can i create a filter for this?? 回答1: public class MyCustomAuthorize : AuthorizeAttribute { protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext) { //if ajax request set status code and end Response if (filterContext

N-Tier Architecture with Service Layer, Business Layer, and Entity Framework

天涯浪子 提交于 2019-12-03 03:43:45
Just wanted some feedback/help with the way I'm architecturing my application. My current solution structure looks something like this: UI (Actual MVC application) Core (only Controllers & ViewModels) Services BLL Data (Entity framework DbContext, mapped to Domain objects) Domain (Simple POCO objects) Interfaces Other stuff Ninject to inject DbContext into Controller (per request) AutoMapper to map Domain objects to ViewModel All assemblies have a reference to the Interfaces project, which, as the name suggests, is nothing more than simple interfaces (i.e. IDbContext, IRepository, etc). The

Proper error handling in ASP.NET MVC2

江枫思渺然 提交于 2019-12-03 03:32:11
I have an override OnException(ExceptionContext filterContext) in my base controller to catch the app during any errors, and then log them. The problem I'm getting in my app is this particular method is fired off four times for certain errors. I'll walk you through a scenario: Let's say i navigate to: http://localhost:180/someController/someAction?someId=XX And I have poor object handling in my code. The Id passed in is an invalid one, and it retrieves some null object, I then, bc of my bad object handling, try to operate on a null object. I get an exception. BaseController's OnException is