Search Results

Search found 9749 results on 390 pages for 'mvc helpers'.

Page 11/390 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • ASP.NET MVC HandleError Attribute

    - by Ben Griswold
    Last Wednesday, I took a whopping 15 minutes out of my day and added ELMAH (Error Logging Modules and Handlers) to my ASP.NET MVC application.  If you haven’t heard the news (I hadn’t until recently), ELMAH does a killer job of logging and reporting nearly all unhandled exceptions.  As for handled exceptions, I’ve been using NLog but since I was already playing with the ELMAH bits I thought I’d see if I couldn’t replace it. Atif Aziz provided a quick solution in his answer to a Stack Overflow question.  I’ll let you consult his answer to see how one can subclass the HandleErrorAttribute and override the OnException method in order to get the bits working.  I pretty much took rolled the recommended logic into my application and it worked like a charm.  Along the way, I did uncover a few HandleError fact to which I wasn’t already privy.  Most of my learning came from Steven Sanderson’s book, Pro ASP.NET MVC Framework.  I’ve flipped through a bunch of the book and spent time on specific sections.  It’s a really good read if you’re looking to pick up an ASP.NET MVC reference. Anyway, my notes are found a comments in the following code snippet.  I hope my notes clarify a few things for you too. public class LogAndHandleErrorAttribute : HandleErrorAttribute {     public override void OnException(ExceptionContext context)     {         // A word from our sponsors:         //      http://stackoverflow.com/questions/766610/how-to-get-elmah-to-work-with-asp-net-mvc-handleerror-attribute         //      and Pro ASP.NET MVC Framework by Steven Sanderson         //         // Invoke the base implementation first. This should mark context.ExceptionHandled = true         // which stops ASP.NET from producing a "yellow screen of death." This also sets the         // Http StatusCode to 500 (internal server error.)         //         // Assuming Custom Errors aren't off, the base implementation will trigger the application         // to ultimately render the "Error" view from one of the following locations:         //         //      1. ~/Views/Controller/Error.aspx         //      2. ~/Views/Controller/Error.ascx         //      3. ~/Views/Shared/Error.aspx         //      4. ~/Views/Shared/Error.ascx         //         // "Error" is the default view, however, a specific view may be provided as an Attribute property.         // A notable point is the Custom Errors defaultRedirect is not considered in the redirection plan.         base.OnException(context);           var e = context.Exception;                  // If the exception is unhandled, simply return and let Elmah handle the unhandled exception.         // Otherwise, try to use error signaling which involves the fully configured pipeline like logging,         // mailing, filtering and what have you). Failing that, see if the error should be filtered.         // If not, the error simply logged the exception.         if (!context.ExceptionHandled                || RaiseErrorSignal(e)                   || IsFiltered(context))                  return;           LogException(e); // FYI. Simple Elmah logging doesn't handle mail notifications.     }

    Read the article

  • Does Java Spring 3.0 MVC support annotation/attribute based client side validation like Asp.net MVC

    - by Athens
    In Asp.Net MVC 2.0, at least in the beta, you could decoration your model classes with data annotation attributes and enable client side validation that leverages that criteria defined in your model data annotation attibutes. Is there anything similar for Java Spring MVC 3.0? Is it possible to inject a component into the response pipeline that can inspect the model's annotated properties and render client side validation logic to complement the server side validation logic that is invoked prior to the controller handling the request?

    Read the article

  • Can ASP.NET MVC html helpers render an element without an ID attribute?

    - by thekaido
    Assume I want to generate an element similar to this in ASP.NET MVC 2: <%= Html.TextBoxFor(p => p.FooBar)%> Is there an overload or way I can get ASP.NET MVC 2 to only generate a name attribute and not an ID attribute? I can have it generate a blank id with <%= Html.TextBoxFor(p => p.FooBar)%>, new { id = "" }, but I would like to generate the element with no ID at all.

    Read the article

  • MVC Authorize Attribute + HttpUnauthorizedResult + FormsAuthentication

    - by Anthony
    After browsing the MVC section on CodePlex I noticed that the [Authorize] attribute in MVC returns a HttpUnauthorizedResult() when authorization fails (codeplex AuthorizeAttribute class). In the source of HttpUnauthorizedResult() from CodePlex is the code (I'm not allowed to enter another URL as my rep isn't high enough, but replace the numbers on the URL above with 22929#266476): // 401 is the HTTP status code for unauthorized access - setting this // will cause the active authentication module to execute its default // unauthorized handler context.HttpContext.Response.StatusCode = 401; In particular, the comment describes the authentication module's default unauthorized handler. I can't seem to find any information on this default unauthorized handler. In particular, I'm not using FormsAuthentication and when authorization fails I get an ugly IIS 401 error page. Does anyone know about this default unauthorized handler, and in particular how FormsAuthentication hooks itself in to override it? I'm writing a really simple app for my football team who confirm or deny whether they can play a particular match. If I enable FormsAuthentication in the web.config the redirect works, but I'm not using FormsAuthentication and I'd like to know if there's a workaround.

    Read the article

  • MVC.NET project won't start under IIS 5.1 on Windows XP SP3

    - by mrjoltcola
    I've a MVC.NET 2 project that runs fine under Windows 7 and will start on Windows XP if I use the Visual Studio Development Server, however, starting under IIS generates an error: Unable to start debugging on the web server With the message The specified procedure could not be found No errors in the system event viewer. If I start without debugging I get an "HTTP 500 Internal Server Error" The reason I run it under IIS is the project also includes some WCF wsHttp web services that use certificates, so the VS Development Server is not adequate for hosting those. I have already seen the links on SO that talk about adding the wildcard mapping. I've already done that, just as I've done on Windows Server 2003 where I successfully host MVC.NET RC2 for quite a while.

    Read the article

  • Visual Studio 2010 Full and ASP.NET MVC 2.0 Template

    - by Daniel
    Hello, I've installed full version (not RC nor Beta) of Visual Studio 2010, a then setup within Web Platform Installer 2.0 announce me that I need to install MVC 2.0, so i did it. When I want to create project "MvcWebApplicationProjectTemplate" in VS I have following message: error: this template attempted to load component assembly 'Microsoft.VisualStudio.Web.Mvc.2.0, Version=10.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. For more information on this problem and how to enable this template, please see documentation on Customizing Project Templates. Any idea how to fix it? Do you think that Web Platform Installer 2.0 might have corrupted this template? Thanks, Daniel

    Read the article

  • Using LLBL as Model in MVC

    - by Quentin J S
    I have settled on trying to use ASP.NET MVC but the first part I want to replace is the Model. I am using LLBL Pro for the model. I have a table called "Groups" that is a simple look up table. I want to take thhe results of the table and populate a list in MVC. Something that should be very simple... or so I thought.... I've tried all kinds of things as I was getting errors like: The model item passed into the dictionary is of type 'System.Collections.Generic.List1[glossary.EntityClasses.GroupEntity]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[glossary.CollectionClasses.GroupCollection]'. private GroupCollection gc = new GroupCollection(); public ActionResult Index() { gc.GetMulti(null); return View( gc.?????? ); } This is all I am trying to do, I've tried lots of variations, but my goal is simply to take the data and display it.

    Read the article

  • ASP.NET mvc on mono 2.2

    - by Markus
    Hi, I am having a trouble. I am trying to run asp.net mvc 1.0 on mono 2.2.I have copied the system.web.mvc.dll to bin directory. I have done HttpContext.Current.RewritePath("/Home/Index");. Still I am having te error: Server Error in '/' Application The incoming request does not match any route Description: HTTP 500. Error processing request. Stack Trace: System.Web.HttpException: The incoming request does not match any route at System.Web.Routing.UrlRoutingHandler.ProcessRequest (System.Web.HttpContextBase httpContext) [0x00000] at System.Web.Routing.UrlRoutingHandler.ProcessRequest (System.Web.HttpContext httpContext) [0x00000] at System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] at MvcApplication4._Default.Page_Load (System.Object sender, System.EventArgs e) [0x00000] at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] at System.Web.UI.Control.LoadRecursive () [0x00000] at System.Web.UI.Page.ProcessLoad () [0x00000] at System.Web.UI.Page.ProcessPostData () [0x00000] at System.Web.UI.Page.InternalProcessRequest () [0x00000] at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433

    Read the article

  • Personalization in ASP.Net MVC -- friendly URLs, and skinning

    - by larryq
    Hi everyone, I haven't delved into custom generation of friendly URLs in ASP.Net MVC, and was wondering if anyone had suggestions. For example, if John Smith were to create an account on www.example.com, I'd like for his homepage to read www.example.com/JohnSmith -- along with the option for him to choose his URL. The ideal is for this to happen with no intervention on my part in the route maps. Also, does anyone have guidelines on good ways to go to customize an MVC site based on URL? Again, using example.com I'd like for John to choose a color theme and logo for his homepage, then apply it accordingly. Thanks for your tips and suggestions.

    Read the article

  • ASP. Net MVC and RegisterClientScriptBlock alternative

    - by Noel
    I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down message text that I use for client side validation e.g. <script type="text/javascript"> //<![CDATA[ var c_errorMessages = { RequiredField : "* Mandatory field" }; //]]> </script> The values are generated on the server side based on culture and resource files. I believe you cannot use RegisterClientScriptBlock with MVC. Any ideas on how I can achieve this with MVC?

    Read the article

  • Does "Debug" invalidate ASP.Net MVC OutputCache?

    - by William Edmondson
    I have images stored in a database and am serving them from an MVC controller as "FileResult". If I run the MVC application from Visual Studio 2008 in debug mode and set a break point inside the controller method the debugger intercepts the call on every page refresh regardless of my "OutputCache" settings. Does the VS debugger invalidate the OutputCache or is there something else going on here? [OutputCache(Duration = 86400, VaryByParam = "id")] public FileResult Index(string id) { byte[] image; int imageId; int.TryParse(id, out imageId); using (var ctx = new EPEntities()) { var imageObj = (from images in ctx.Images where images.ID == imageId select images).FirstOrDefault(); image = imageObj.Image; } return new FileContentResult(image, "image/gif"); }

    Read the article

  • ASP.NET MVC The new ActionLink with MvcHtmlString and request URL generated

    - by mare
    This piece of code used to work in MVC 1 but it does not since I upgraded to MVC 2: <%=Html.ActionLink(Resources.Localize.Routes_WidgetsCreate, "Create" + "?modal=true", "Widget", null, new { rel = "shadowbox;height=600;width=700", title = Resources.Localize.Routes_WidgetsCreate })%> I am aware it has something to do with the way ActionLink encodes things, so the result that comes out is something like this: "http://localhost:53704/Widget/Create%3fmodal%3dtrue" The problem is, when clicked, the Shadowbox modal opens up and inside, where the request View should be rendered is this exception: Server Error in '/' Application. A potentially dangerous Request.Path value was detected from the client (?). What can I do to get past that? Do you recommend another way of sending params to the view besides in QueryString (in this case I need "modal" because in the view I select CSS styles based on whether we are rendering modal or not)?

    Read the article

  • MVC architectural question - Where should payment processing go?

    - by Keltex
    This question is related to my ASP.NET MVC 2 development, but it could apply to any MVC environment and a question of where the logic should go. So let's say I have a controller that takes an online payment such as a shopping cart application. And I have the method that accepts the customers' credit card information: public class CartController : Controller CartRepository cartRepository = new CartRepository() [HttpPost] public ActionResult Payment(PaymentViewModel rec) { if(!ModelState.IsValid) { return View(rec); } // process payment here return RedirectToAction("Receipt"); } At the comment process payment here should the payment processing be handled: In the controller? By the repository? Someplace else?

    Read the article

  • MVC 2 Conversion Disrupts the parameters passed to my Stored Procedure

    - by user54197
    I have a few textboxes that are not required. If the user enters nothing it is passed as 'null' in MVC 2. It was passed as '""' in MVC 1. What changes can I make to accomodate for this? public string Name { get; set; } public string Offer{ get; set; } public string AutoID { get; set; } using (SqlConnection connect = new SqlConnection(connections)) { SqlCommand command = new SqlCommand("Info_Add", connect); command.Parameters.Add("autoID", SqlDbType.BigInt).Direction = ParameterDirection.Output; command.Parameters.Add(new SqlParameter("name", Name)); //Offer now returns a null value, which cannot be passed command.Parameters.Add(new SqlParameter("offer", Offer)); command.CommandType = CommandType.StoredProcedure; connect.Open(); command.ExecuteNonQuery(); AutoID = command.Parameters["autoID"].Value.ToString(); }

    Read the article

  • ASP MVC 2 : Custom display of a required form element based on ModelMetaData

    - by Nigel
    I have an MVC 2 application that utilises forms. The required fields within the form are set using attributes that update the model metadata. The form fields are created using the MVC HtmlHelper method : Html.EditorFor. This works fine so far as validation is concerned, but it seems that by default the required fields are not displayed to the user (for example by appending a * to the control). If I wanted to provide some custom means of displaying this fact to the user (lets immagine I want to change the background colour of the edit control for example), where is the best place to do it. Would I need to create a custom html helper to replace EditorFor? I tried but it seemed difficult to gain access to the metadata for the correct property. I already have a custom ModelMetaDataProvider so there is no problem adding it there if that is the correct place.

    Read the article

  • How do I maintain scroll position in MVC?

    - by Eric Brown
    Im working on a project in MVC and have enjoyed learning about it. There are a few growing pains but once you figure them out it's not bad. One thing that is really simple in the WebForms world is maintaining the scroll position on a page. All you do is set the MaintainScrollPositionOnPostback property to true. However, in MVC, Im not using postbacks so this will not work for me. What is the standard way of handling this? Edit: Ajax is acceptable, but I was also wondering how you would do it without AJAX.

    Read the article

  • ASP.NET MVC: post-redirect-get pattern, with only two overloaded action methods

    - by Rafi
    Is it possible to implement post-redirect-get pattern, with two overloaded action methods(One for GET action and the other for POST action) in ASP.NET MVC. In all of the MVC post-redirect-get pattern samples, I have seen three different action methods for the post-redirect-get process, each having different names. Is this really required? For Eg:(Does the code shown below, follows Post-Redirect-Get pattern?) public class SalaryTransferController : Controller { // // GET: /SalaryTransfer/ [HttpGet] public ActionResult Index(int id) { SalaryTransferIndexViewModel vm = new SalaryTransferIndexViewModel(id) { SelectedDivision = DivisionEnum.Contracting }; //Do some processing here return View(vm); } // // POST: /SalaryTransfer/ [HttpPost] public ActionResult Index(SalaryTransferIndexViewModel vm) { bool validationsuccess = false; //validate if (validationsuccess) return RedirectToAction("Index", new {id=1234 }); else return View(vm); } } Thank you for your responses.

    Read the article

  • asp.mvc model design

    - by Radu D
    Hi, I am pretty new to MVC and I am looking for a way to design my models. I have the MVC web site project and another class library that takes care of data access and constructing the business objects. If I have in that assembly a class named Project that is a business object and I need to display all projects in a view ... should I make another model class Project? In this case the classes will be identical. Do I gain something from doing a new model class? I don't like having in views references to objects from another dll ... but i don't like duplicating the code neither. Did you encounter the same problem?

    Read the article

  • View artifacts leaking into the model of MVC

    - by Jono
    In an ASP.NET MVC application (which has very little chance of having its view technology ported to something non-HTML, but whose functional requirements evolve weekly,) how much HTML should ideally be allowed to be directly represented in the Model? I might come across as a design bigot for this, but I regard it as bad practice to allow any view constructs to "leak" into the model in an MVC application (and vice versa). For example, a Model that represents an item you're about to purchase should know nothing about the HTML check box that says "add giftwrap/message", nor should it know about any HTML drop down lists for payment card types. Conversely the View shouldn't be doing work like figuring out button text by translating keys into values (by looking in resource files.)

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >