asp.net-mvc

ASP.NET MVC: Custom parameters to login page after authorization

I would like to redirect visitors to a login page with added parameters (based on the action they are performing) after the authorization fails. This is an example of what I would like to do: http://stackoverflow.com/questions/835672/asp-net-mvc-customeauthorize-filter-action-using-an-external-website-for-loggin However, since this is...

Importing parts from X number of folders using MEF

I have a number of folders that all contains MEF parts that should be imported. Is the easiest way to find all the parts to iterate over the folders and create a MEF Aggregating Catalog object? I need to place the parts in different places in the application based on the folder it was read from. So parts from folder "Test1Parts" should ...

How can you use ASP.NET MVC build from source rather than the GAC?

I've installed the ASP.NET MVC locally, but I want to be able to use the code that is in the SVN repository on CodePlex rather than the released 1.0 version. However if I remove the reference to the GAC assembly in my solution and add the reference to the locally built System.Web.Mvc, it will build fine, but at runtime it says: Pars...

How to handle membership in an ASP.NET MVC application?

How would you handle membership in an ASP.NET MVC application? Using any external libraries? How would you do OpenID log in? username log in? email log in? any other that is worth looking into? Maybe all of them mixed into the application? It seems ASP.NET comes with some pre-build user database (I'm totally new to .Net). The NerdDinner...

Administration Area in Asp.Net MVC

Hi, My question may be obvious but I'd like to build a well-designed web application. As for any administration area, the admin should be able to list/create/delete/modify users, articles, posts, etc... I'd like to know what is the best way to design the application. Should I create a controller for each one of those items (/Users/Crea...

Redirect to Page when not paid

I am using MVC with C#. I need to take the user to a payment page if the user didn't pay for an item. I need to have a common class to check this functionality and redirect to payment page. Like inheriting all the controllers to a Base Controller. In that base controller i have to check this payment status for some controller and action...

ASP.NET MVC - How to get Ajax 'onclick' for a specific action (I need for Ajax.ActionLink what Url.RouteUrl does for Html.ActionLink)

Hi, REVISION I want add a onclick to a element that handles a Ajax request, not just a route-redirect. I have these options for a route-url. Html.ActionLink(params) Url.RouteUrl(params) 'returns JUST ActionUrl So I can go like <div onclick="javascript:location.href('<%=Url.RouteUrl(params)%>')"></div> But how do I generate t...

ASP.NET MVC - Can I create an invisible Ajax.ActionLink() ?

Is it possible to create an invisible Ajax.ActionLink? Ajax.ActionLink("", "Action", Args, AjaxArgs) The above doesn't work, LinkName (1st argument) cannot be Null or Empty... ...

ASP.Net-MVC sample code to retrieve selected item from html dropdownlist

Can somebody give me an sample code to retreive the item from html.dropdownlist? ...

could you convert this line of c# into vb.net?

I tried many things but I always get "cannot convert string to membershipuser" from the ASP.Net MVC Membership Starter Kit this line from file ListUsers.aspx var users = (ViewData["Users"] as List<MembershipUser>); ViewData["Users"] come from public virtual ViewResult Index( int? pageIndex, int? pageSize ) { ViewData["Title"] =...

Bad request 400 for HttpUtility.UrlEncoded URL segments

So, if there are url encoded segments in my apps MVC url, IIS throws a BAD REQUEST 400. e.g. http://u.lasoo.com.au/Offer/*9289--750W-Generic-ATX12V-Power-Supply-%252449dot99/6355 <--- the '*' and '%' are causing this error. Notice that http://u.lasoo.com.au/Offer/The-Giant-Good-As-Gone-7-Day-Sale/6354 works fine. What's the correct ...

ASP.NET MVC Ajax - Is it possible to execute a -GENERATED- Ajax link with keyboard input?

Is anybody able to -execute- a generated Ajax.ActionLink when a user presses a key on the keyboard? (This is needed for accessibility) NOTE: I'm using ASP.NET MVC + Microsoft Js libraries (...Ajax.js / ...MvcAjax.js) + jQuery Javascript to capture keypress (IE + Firefox) $(document).keypress(function(event) { if(event.keyCode == 2...

MVC Ajax not posting a dropdownlist value

Using the following form in a view <% using (Ajax.BeginForm("PatientSearch", new {}, new AjaxOptions() { HttpMethod = "POST", UpdateTargetId = "searchResults", OnBegin = "BeginRequest", OnSuccess = "SuccessRequest", OnFailure = "FailRequest" ...

Injecting Javascript and HTML from HTMLHelper or From User control IN ASP.NET MVC

hi, i have been reading this interesting article which is increasing my every growing confusion about best practices in MVC link text and there is a very hot debate about wither to inject JavaScript and HTML Tags using an HTMLHelper or putting it in User control. what do you advise ? in case you advise putting it in user Control, how...

How do you debug "No route in the route table matches the supplied values." in ASP.NET MVC

I seem to run into this error all the time: No route in the route table matches the supplied values. An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. The stack trace is just a bunch of MVC ga...

Easy way to check for view model changes in asp.mvc

Is there a easy way of checking a view model(Not Domain Model) for modifications in the post back? public ActionResult Billing() { var viewModel = new BillingViewModel(); viewModel.prop1 = DomainService.Prop1 // Map Domain model to View Model return View(viewModel); } [AcceptVerbs(HttpVerbs.Pos...

Apply an action filter to every controller in only one part of an ASP.NET MVC site?

I've seen a great answer to a similar question which explains, by inheriting all controllers from a new base class decorated with your own ActionFilter attribute, how you could apply some logic to all requests to your site. I'd like to find a way to do that based on the area of a site my user is visiting. For example, I will have a Pro...

ASP MVC View Content as JSON

I have a MVC app with quite a few Controller Actions that are called using Ajax (jQuery) and return partial views content which updates a part of the screen. But what I would rather do is return JSON something like this. return Json(new { Result = true, Message = "Item has been saved", Content = View("Partial") }); Whe...

Mvc.FormatDescription error in ASP.NET

Hi there, I'm testing the security of my application and by injecting some quotes in one of my parameters, the system returns the following error: Invalid token, expected closing quote ' on {busobj:Mvc.FormatDescription('{var:entity=Transactions.Allowance,idValue=069'"}')} I did not successfully find anything that could explain what ...

FileResult with MemoryStream gives empty result .. what's the problem?

Hi, I'm generating ics files ( iCalendar or RFC 2445 or however you call them) using a library that serializes the ical contents into a MemoryStream, or actually any type of stream. Here's my chunk of code: public ActionResult iCal(int id) { MyApp.Event kiEvt = evR.Get(id); // Create a new iCalendar iCalen...