MVC :: A Catch-all Parameter Can Only Appear As The Last Segment Of The Route URL?

Mar 26, 2010

I have this dynamic url and part of it will going to have paging enabled ike, "http://localhost:96556/MVC_Application/proceedings/url_link/url_section/url_item/url_position/page/2"But I'm getting this error at my route below "A catch-all parameter can only appear as the last segment of the route URL.Parameter name: routeUrl"

routes.MapRoute( _
"UrlItemProceedings", _
"proceedings/{*catchPath}/page/{page}", _

[code]...

View 2 Replies


Similar Messages:

MVC :: Bug - Get Value From Route Parameter Instead Of Property Of Model

May 18, 2010

I found little bug feature in MVC 2.

So, if we have in route defined parameter with same name as property at model and then we call it from strongly typed HTML helper (for example Html.TexBoxFor(x => x.PropertyName)), we get value from route parameter instead of property of model.

For example.

We have defined follow route:

[Code]....

Very simple model:

[Code]....

Next action in controller:

[Code]....

And very simple view:

[Code]....

Result you can see at follow picture:

I think what this dirty example described the essence of the problem. Let me know if I'm wrong.

View 1 Replies

Getting Null Parameter Value In Controller When MVC Route Fires?

Jan 12, 2011

I'm using a custom route to create the following URL (http://mysite/subscriber/12345) where 12345 is the subscriber number. I want it to run the ShowAll action in the Subscriber controller. My route is firing and using Phil's route debugger, when I pass in the above url, the route debugger shows ID as 12345.

My controller is accepting an int as subscriberID. When it fires, the controller throws the error "The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32". Why does the route debugger show a value and the controller doesn't see it?

Here's my route (first one is the culprit)

routes.MapRoute(
"SubscriberAll",
"subscriber/{id}",
new { controller = "Subscriber", action = "ShowAll", id=0 },
new { id = @"d+" } //confirm numeric
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

I'm getting a null in the ShowAll action? Here is the action method signature:

public ActionResult ShowAll(int id)

View 3 Replies

Custom Route With More Than One Parameter In Url (customer - Extra Info)

Jan 31, 2011

I have a multi tenant system and I need to allow administrators to edit the information of other customers. I believe the correct way to do this is to append the customer ID to each request, and update my routes accordingly. How do I make ASP.NET accept and use something like this in the controller (order doesn't mean much to me): [URL] and how would I pass and consume that in my controller? The ASP.NET tutorials skip this... (or I don't know where to search)

View 1 Replies

MVC Routes Adding An Optional Parameter At The Beginning Of A Route

Aug 7, 2010

I have the following routes setup in my route config file. I have a config reader that maps these to MVC-style routes.

[route name="customers" url="customers/{statename}/{marketname}/{pagenumber}"]
[controller name="Customers" action="Display" //route]
[route name="pcustomers" url="{customername}/customers/{statename}/{marketname}/{pagenumber}"]
[code]...

View 2 Replies

MVC :: Route Parameter Reversed On Form Submit Button Click?

Jan 25, 2011

As the title says when I click the submit button on my form, instead of taking me to the next form with a url of controller/action/id or /action/id I am getting a nice 404 with a url of /id/action

The offending action is called IntakePage2. Typing the correct route manually works.

My routes are as follows:

[Code]....

The relevant controller code is as follows:

[Code]....

The partial that IntakePage1 loads:

[Code]....

<%}%>

IntakePage2 main page (The partial it references just has the text "boo" in it at the moment. It is intended to take an InsertViewModel object at some point.)

[Code]....

View 3 Replies

How To Pass JavaScript Function As A Parameter In The Route Values Of Ajax Actionlink

Apr 20, 2010

I need to pass javascript function as a parameter value to the ajax actionlink in asp.net mvc app. how can we achieve this?

View 1 Replies

DataSource Controls :: Catch Don't Catch Any Error From SQL 2000 Transition Store Procedure

Feb 7, 2010

Here is the code copied from [URL] In asp.net code behind, I use try-catch try to catch any error but never catch it. In SQL database, if I rename Employees to Employeesx or change column DepartmentID to DepartmentIDx, record will not be deleted (it is right) without any error (it is wrong, suppose catch an error).

CREATE PROCEDURE DeleteDepartment
(
@DepartmentID int
)
AS
BEGIN TRANSACTION
DELETE FROM Employees
WHERE DepartmentID = @DepartmentID
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error', 16, 1)
RETURN
END
DELETE FROM Departments
WHERE DepartmentID = @DepartmentID
IF @@ERROR <> 0
BEGIN
ROLLBACK
RAISERROR ('Error', 16, 1)
RETURN
END
OMMIT

View 2 Replies

Get IP With Different Segment Or Gateway?

Jan 29, 2015

I'm trying to develop local website that records and save to sqlserver the private ip of person who will login to my website, Im using Windows Server r2 as my server, Now my problem is it only records the IP with same segment of my server which is segment zero like(192.168.0.83), if the IP of user is segment 1 or 2 the only the Default gateway of their IP are being saved, Correct me if I am wrong if it is defends on segment or gateway.

Code:
if (string.IsNullOrEmpty(HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]))
{
Label2.Text = (Request.ServerVariables["REMOTE_ADDR"]);
}
else
{
Label2.Text = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"]);
}

View 2 Replies

MVC :: Webforms Route / Implementing Route In Global.asax

Mar 13, 2011

I tried to mix asp.net 4 webfrom and ASp.Net MVC 3. I add required lines in webconfig, but I've issues implementing route in global.asax

Currently I use several routes for webfroms. routs template are like below

routes.MapPageRoute("Node", _
"article/sport/{nID}/", _
"~/article/articleview.aspx")

I encounter error, when I add below lines to global.asax

routes.MapRoute( _
"Defaultss", _
"{controller}/{action}/{id}", _
New With {.controller = "Home", .action = "Index", .id = UrlParameter.Optional} _
)

I want to know how could I mix ASp.Net MVC routes with webforms routes.

View 3 Replies

Segment C# Projects On Single Base?

Apr 4, 2011

I have a base project (with all its glory, dlls, resources etc) which is a CMS. I need to use this project as a base for othe custom bake projects. This base project is to be maintained and updated among all custom bake projects. I use subversion (Collabnet and Tortise SVN) I have two questions:

1 - Can I use subversion to share the base project among other projects What I mean here is can I "Checkout" the base project into another "Checked Out" project and have both update and commit seperatley. So, to paint a picture, let's say I am working on a custom project and I modify the core/base prject in some way (which I know will suit the others) can I then commit those changes and upon doing so when I update the base project in the other "Checked out" resources will it pull the changes? In short, I would like not to have to manually deploy updated core files whenever I make changes into each seperate project.

2 - If I create a custom file (let's say an webcontrol or aspx page etc) can I have it compile seperatley from the base project Another tricky one to explain. When I publish my web application it creates DLLs based on the namespaces of projects attached to it. So I may have a number of DLLs including the "Website's" namespace DLL, which could simply be website. I want to be able to make a seperate, custom, control which does not compile into those DLLs as the custom files should not rely on those DLLS to run. Is it as simple to set a seperate namespace for those files like CustomFiles.ProjectName for example? Think of the whole idea as adding modules to the .NET project, I don't want the module's code in any of the core DLLs but I do need for module to be able to access the core dlls.

(There is no need for the core project to access the module code as it should be one way only in theory, though I reckon it woould not be possible anyway without using JSON/SOAP or something like that, maybe I am wrong.) I want to create a pluggable environment much like that of Joomla/Wordpress as since PHP generally doesn't have to be compiled first I see this is the reason why all this is possible/easy. The idea is to allow pluggable themes, modules etc etc. (I haven't tried simply adding .NET themes after compile/publish but I am assuming this is possible anyway? OR does the compiler need to reference items in the files?) I posted a similar question with a little more detail for question 2 on Experts-Exchange. I don't want to post all that info here as it just will be too messy but it explains question 2 in greater detail.

View 2 Replies

C# - How To Store And Retrieve A Particular Segment From The Cache

Mar 8, 2011

It should store plain HTML fragments of a page like the standard Output cache in asp.net .The HTML may contain dynamic content from a database.When an object is updated in the database all the cached HTML fragment containing that particular object should be destroyed and re-cached next time it will be requested.

There is a separate admin tool to handle all data in the database so I can easy store the Id's in a cachetable when an object is invalid. I can also make a request to a page that destroy all cached HTML fragment for that object.

But when I write the markup, how could I do to store and retrieve a particular segment from the cache? Of cause I could do this in code behind and have the markup in a string but I don't want that. I want to have the markup as intact as possible.

View 2 Replies

Getting Unhandled Exception But Unable To Catch With Try Catch

Sep 14, 2011

I get this error in the browser:

Code:
Thread was being aborted.

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.Threading.ThreadAbortException: Thread was being aborted.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ThreadAbortException: Thread was being aborted.]
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +486
System.Web.ApplicationStepManager.ResumeSteps(Exception error) +501
System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +123
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +379

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

I have try{}catch(Exception ex){} in the right place:

Code:
protected void Button1_Click(object sender, EventArgs e)
{
try
{
// all processing occurs inside here
}
catch(Exception ex)
{
}
}

I even created a global.asax file and on the Application_Error event, I wrote a code that would email me the error (and i'm not getting an email regarding that error when I get the error shown above). I know for a fact that the thread is going inside the "try" statement because I send emails to myself whenever it finishes certain codes inside of it. So how come I'm getting that error in my browser instead of it being handled in my "catch" statement? I have two problems here, one, why is the exception not going to my "catch" statement, and two, why am I getting that error in the first place.

Note: my web app calls a webservice.

View 2 Replies

MVC :: A Route Named 'Admin_default' Is Already In The Route Collection?

Mar 9, 2010

when i run the app i got this error

A route named 'Admin_default' is already in the route collection. Route names must be unique.
Parameter name: name

this is my AdminAreaRegistration

[Code]....

View 2 Replies

ADO.NET :: Reading A Segment Of Huge Varbinaty (max) Field By DataReader

Oct 19, 2010

I have a table with just a column and a row in a table that it save just a file with size 1.5 GB ! C# application and sql server are in different machines. I want to read that file by DataReader every 100 MB then save all 100 MB files to disk by "FileMode.Append" for file stream and collect them to one file.

View 1 Replies

Route Constraints And Empty Route?

Sep 24, 2010

I have a url that I want to map routing to:

[URL]

where tabvalue is one of: "personal", "professional", "values" or nothing.

I want to map it to a route like:

Member/Edit/{tab}

But my problem is - I don't know how to specify such constraints. I'm trying this regex:

^[personal|professional|values]{0,1}$

but it only works when I use url

[URL]

[URL]

and doesn't work for

[URL]

how to specify the correct constraint?

P.S. I'm not using MVC, just asp.net WebForms

View 6 Replies

C# - MVC 3 Custom Route Handler - Skip To Next Custom Route Rule?

Mar 14, 2011

Was looking at asp.net mvc complex routing for tree path as an example of how to define a custom route handler for my MVC app. Essentially, I want to give the end user ultimate flexibility in defining the URL for any given page, so I provide them with a field in the interface to specify their own custom URL.

My custom route handler is basically a wild-card handler. It will do a lookup and if it finds a match, map it accordingly. However, if no match is found, I want it to fall back and find the next rule that matches in the global.asax. Is that possible? Or do I essentially need to code the mappings that used to exist in my global.asax into my custom route handler?

View 2 Replies

Forms Data Controls :: Column Chart Has Inconsistent Column Segment Widths?

Jan 3, 2011

[Code]....

Stacked-column chart has inconsistent column segment widths

View 1 Replies

SQL Reporting :: MDX Query Parameter From SSRS / Setup @from And @to As Parameter But Not Working?

Aug 21, 2010

I've a MDX Query that has where clause as shown below.I'm designing report using SSRS 2008. How can i pass date as parameter? I tried to setup @from and @to as parameter but not working?

WHERE ( {[Date Central].[Calendar Date].[2010-04-01 00:00:00]:[Date Central].[Calendar Date].[2010-08-30 00:00:00]} )

need it to work as
WHERE ( {[Date Central].[Calendar Date].[@From]:[Date Central].[Calendar Date].[@To]} )

View 1 Replies

SQL Reporting :: Change Parameter Property After Selecting Another Parameter?

Oct 19, 2010

Is it possible to change a parameter's property after the uer has made a selection or filled in another parameter field? I'm using VS2005

Case:

- 3 parameter fields; Country,Station,Carrier all three are textfields and are allowed to stay 'blank'.

- When the user enters a Country-code in the 'Country' parameter field, the 'Carrier' parameter should become a required field.

I did some searching on the net, but haven't found the solution. I started to wonder if it's actually possible?

View 6 Replies

SQL Reporting :: Parameter Enabling Based On Selection In Another Parameter?

Nov 12, 2010

I have a parameter Owner with 1,2,3 options in dropdown.

On selection of option 1 , a country parameter should be enabled with all countries' values defaulted.

Option 2 should enable Region parameter with all the Regions values selected and country parameter should be displayed.

Option 3 should disable both Region & Country Parameter.

I am using SSRS 2005 with Enesys tool as add on.

View 2 Replies

SQL Reporting :: Create Another Parameter That Acts A Filter For The Other Parameter?

Jun 26, 2010

One of our customers has a report with a single value string parameter that has over 1000+ possible values. selecting single value from 1000+ choices results in bad UI, among other things.create another parameter that acts a filter for the other parameter. So you would have Param1 with say 25 choices and selecting a choice would narrow down the option for the second parameter.Is this the best way. What is the best practice for handling these kinds of parameters?

View 5 Replies

Forms Data Controls :: Setting The ID Parameter To Form Parameter Source And Have Entered The Grid Views Name In The Form Field

Mar 11, 2010

How do you use the http POST method with a Grid View on another page. I am trying to use the POST method to send the ID from the selected row of a Grid View, I am using a link button set to fire the select command and it has the Post Back URL set, from one page and then retrieve the ID value on another page using an Object Data Source. Also, under the Defining Parameters, I am setting the ID parameter to Form Parameter Source and have entered the Grid Views name in the Form Field.

View 4 Replies

How To Use Try ,catch In Asp.net

May 29, 2010

Here i have small doubt,how can i use try and catch.Please give me brief idea.hen ever an error is raised in try block,how to handle it in catch.is it enough to give message for user or shall i handle there it self?

View 7 Replies

MVC :: How To Add A Certain Route

Apr 5, 2010

I want to do the following:

routes.MapRoute("testwithoutcontroller", "Overview/Index/{year}", new {year = 2010});

But it fails when I call Overview/Index/2010 and gives me this error:

The RouteData must contain an item named 'controller' with a non-empty string value.

What must I do in order to only have Overview/Index be possible for my route?

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved