.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Route Constraints

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
If I have a route mapped as follows, how can I add a constraint for the route values with periods in?routes.MapRoute( "", "Created/{Created.Year}/{Created.Month}/{Created.Day}/Page/{Page}", new { controller = "Blah", action = "Blah" }, new { Page = @"\d+" });

View Complete Post

More Related Resource Links

ReportViewer :: Failed to enable constraints. But my statement is valid!!

  • A
  • n error has occurred during report processing.
      • Exception has been thrown by the target of an invocation.
        • Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    Why do I keep getting this error, even when not using any data on the report. When I run the query in SQL server I get a resultset. However when I try to render the report I get this error.


    Data Points: Disabling Constraints and Triggers


    What to do when you need to disable triggers and constraints to perform data synchronization and other tasks with an offline database.

    John Papa

    MSDN Magazine April 2007

    How to script default constraints using SMO

    I have developed a db copy tool using smo and the only thing that I cannot get to work is the transfer of a default constraint. We have two types of copies. Full and clean. The full is one might expect a simple backup and restore. A clean is a db built from scratch transfering the schema and then data for a subset of tables. It is the clean copy where I cannot get the default constraint to work. I hope I am just missing setting an option. Code is as follows:   Transfer cleanCopySchema = new Transfer(sourceDatabase); cleanCopySchema.CopyAllTables = true; cleanCopySchema.DropDestinationObjectsFirst = true; cleanCopySchema.Options.IncludeIfNotExists = true; cleanCopySchema.Options.WithDependencies = false; cleanCopySchema.Options.ContinueScriptingOnError = true;   cleanCopySchema.CopyData = false; cleanCopySchema.CopyAllUserDefinedFunctions = true; cleanCopySchema.CopySchema = true; cleanCopySchema.DestinationServer = destinationServer.Name.ToString(); cleanCopySchema.DestinationLoginSecure = true; cleanCopySchema.DestinationDatabase = request.DestinationDatabaseName; cleanCopySchema.CopyAllUsers = false; cleanCopySchema.CopyAllLogins = false; cleanCopySchema.CopyAllStoredProcedures = true; cleanCopySchema.CopyAllViews = true; cleanCopySchema.Options.DriAll = true; cleanCopySchema.Options.Indexes = true; cleanCopySchema.Options.DriDefaults = true; cle

    MVC Route with multiple id: controller/action/id1/id2

    Hi, I'd like to provide a route which handles a URL like this: 'http://my.com/Shop/Departments/Garden/Rakes' Is there a way to create a route which picks up & passes in the parameters 'Garden' and 'Rakes'? Or do I need to take 'Garden/Rakes' from one id parameter as a string and handle it myself? Thanks, +M    

    How can i route to different actions having same signature if i don't want to pass action name in U

    I am having one controller Test having following actions (1)public ActionResult ABC (string parameter1, string parameter2)       (2)public ActionResult XYZ (string parameter1, string parameter2,string parameter3, string parameter4)       i have added following html.routelinks  <%= Html.RouteLink("ABC","ABC", new { parameter1 = 100, parameter2 = 200 } )%><br /> <%= Html.RouteLink("XYZ", "XYZ", new { parameter1 = 1000 , parameter2 = 2000 }) %> last two parameters in XYZ action are optionals so i have not passed them in Html.routelink  routes.MapRoute("ABC", "Test/{parameter1}/{parameter2}", new { controller = "Test", action = "ABC", parameter1= 0,parameter2=0 }); routes.MapRoute("XYZ", "Test/{parameter1}/{parameter2}/{parameter3}/{parameter4}", new { controller = "Test", action = "XYZ", parameter1=0,parameter2=0 ,parameter3=UrlParameter.Optional,parameter4=UrlParameter.Optional}); In above senario in both cases same route "ABC" is called eventhough i have clicked on second Html.routelink.can anyone solve this issue ? how can i route according to route name instead of number of parameters?

    SSRS 2008 R2 Data Source View Wizard does not recognize unique key constraints on views when using O

    Hi, SSRS Data Source View Wizard does recongnize Primary/Foreign Key relationships from oracle datasouce tables, but does not recognize unique key constraints on views. How can I solve this problem. Thanks

    Any way to re-route soap request to different method using soap extensions?

    Not sure if this is possible, but is there any way (using soap extensions) to intercept a soap message and re-route it to a different method on the web service host?  I am able to intercept and replace the method name in the xml, but it still goes to the original method.

    Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign

    Using Visual Studio with MySQL.In my XSD dataset I created a query. It runs perfect. I can preview the data fine.In my BLL I wrote code (see below) to retrieve the query results and I'm getting...Using db As New dsDemoTableAdapters.DemoTableAdapter Dim dt As New DataTable dt = db.GetDemo(DemoId) ' ERROR HAPPENS HEREFailed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.Why would previewing the data work but in code it fails?Any ideas?

    Defining Constraints - SRS or SDD?


    Where should I define any application/database level constraint - In the Software Requirement Spefications (SRS) or Software Design Document SDD. e.g. An EmployeeID is unique OR If we update a particular value, a log entry is made. And in the respective SRS or SDD, any particular section?

    asp.net forms authentication with route handling - error, routes not recognized, returns to login


     I just created a small site with form authentication with route handling.  Without forms authentication, the pages route just fine.  With forms, it returns back to the login page as it is not one of my allowed locations specified in my web.config file.


    I know I probably need to write a custom route handler.  Does anyone have an example I can follow for this?  Thanks.

    Creating table records with foreign key constraints/Separate controllers?


    I have multiple tables that are all linked back to a central table with foreign keys. I want to be able to create a new record in table 2, but I'm having trouble because I don't know how to create a new instance of table 2's record while referencing the ID of the record it will be tied to.


    URL Routing Regular Expression Constraints


    I have a URL route that looks like this:


    All of the ID values are numeric so are easy to extract with regular expressions, but the "market", "community" and "floorplan" values can be any string INCLUDING (and here's the problem spot), words with hyphens in them. Consider the following URL:


    What regular expression constraints can I use so that:


    Just using numeric constraints works when there are no hyphens in the market, community or floorplan names but it breaks when hyphens exist:

    Here's what I have (just toying around with it -- I'm horrible at regular expressions):


    failed to enable constraints error




    I am getting below error when trying to display list of providers, i really appreciate feedback on troubleshooting and fixing it.



    Server Error in '/testload' Application.

    Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    Description: 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.

    Exception Details: System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

    Source Error:

    Line 4828:            End If
    Line 4829:            Dim dataTable As hivsystem.providersDataTable = New testloadsystem.providersDataTable
    Line 4830:            Me.Adapter.Fill(dataTable)
    Line 4831:            Return dataTable
    Line 4832:        End Function

    routeValues does not route Values



    Straight to the point:

    Songs Create Action Method

    public ActionResult Create(Album album, Song song)

    Albums Create.aspx

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Namespace.Album>" %>
    <% using (Html.BeginForm()) {%>
    // ... FORM FOR THE ALBUM ...
    <input type="submit" value="Create" />
    <% } %>
    <% using (Ajax.BeginForm("Create", "Song", new { album = Model }, new AjaxOptions() { UpdateTargetId = "List", HttpMethod = "POST" }))
    { %>
    <div id="Form">
         <% Html.RenderAction("Create", "Song"); %>
    <input type="submit" value="Create" />
    <% } %>
    <div id="List">
         <% Html.RenderAction("Index", "Song", new { objs = Model.Songs }); %>

    When I submit the Song, the Song's Create Action Method album object is NULL. How is that possible if I set it to be the Model?



    How disable constraints in MVC??


    I have this 2 pasrial class:

    public partial class Dinner :EntityObject {
            // with properties

    and second for validators

        public partial class Dinner {
        public class Dinner_Validation {
            [Required(ErrorMessage = "Title is required")]
            [StringLength(50, ErrorMessage = "Title may not be longer than 50 characters")]
            public string Title { get; set; }
            [Required(ErrorMessage = "Description is require")]
            [StringLength(265, ErrorMessage = "Description must be 256 characters or less")]
            public string Description { get; set; }
            [Required(ErrorMessage = "Address is required")]
            public string Address { get; set; }
            [Required(ErrorMessage = "Country is required")]
            public string Country { get; set; }
            [Required(ErrorMessage = "Phone# is required")]
            public string ContactPhone { get; set; }
            [Required(ErrorMessage = "EventDate is required")]
            public DateTime EventDate { get; set; }
            [Required(ErrorMessage = "HostedBy is required")]
            public string HostedBy { get; set; }
            [Required(ErrorMessage = "Lat

    Help with Registering a Route


    I have a route that is working correctly in the form of the standard:


    Example real URL is:


    I would like to remove the "Index" from the URL so that when a user enters:


    ...the Index view is still rendered.

    Note that my ProjectID's always start with "PRJ"


    1) How do I register this route in my Global.asax.cs file?

    2) How would I generate the correct link (minus the "Index") in my views using Url.Action()?

    This is what I tried:

                    "View Project",
                    new { controller = "Project", action = "Index" },
                    new { id = @"/^PRJ/" }      //regex constrains this route to only work if {id} begins with "PRJ"

    Encoding of route values


    Says I have simple route: "Begin/{Url}/End"

    I want to genereate url for this route with Url = http://test - the result should be /Begin/http%3A%2F%2Ftest/End

    But any url generation methods work incorectly:

    new Route( "Begin/{Url}/End", null ).GetVirtualPath(
      new RouteValueDictionary( new { Url = "http://test" } ) ).VirtualPath

    returns - Begin/http%3a//test/End, any attempts to pre-encode an urls gives double-encoded values.

    .net 4.0, mvc 2.0

    ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
    Sql Server  SharePoint  Silverlight  Others  All   

    Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend