.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

Question about custom routing

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :ASP.Net

Hi all,

I have to admit in advance that I'm quite new to MVC, I've been going through the resources at asp.net/mvc, but I was wondering if you guys could help me with something.

I have been asked to create a ASP.NET version of an existing PHP website, this website has a huge number of existing links to it in a particular format, which I have to replicate in due to the amount of work to change all the existing links would be far too much.

The format of the existing links is;


My attempt at creating a custom route doesn't appear to be working. What I have done is change the RegisterRoutes method in Global.asax.cs file to be;

public static void RegisterRoutes(RouteCollection routes)

        new {controller="ExistingLinkController", action="Index"},
        new {LinkId = @"([A-Za-z0-9]{14})", Title = @"([A-Za-z0-9_-]*)

View Complete Post

More Related Resource Links

Question on Custom Delivery Extension

All, I want to add new File Based report subscriptions option as "Custom CSV Format". I am bit confused about Custom Delivery Extension and Custom Rendering Extension. My question is for this requirement, should I create Custom Delivery Extension or Custom Rendering Extension? Becaue What I see in rsreportserver.config file, the Rendering Extension defined under <Extension></Extension> tag are available for File Based report subscriptions So is there any relationship between them? Please point me to right direction.

Question on Custom Delivery Extension

All, I want to add new File Based report subscriptions option as "Custom CSV Format". I am bit confused about Custom Delivery Extension and Custom Rendering Extension. My question is for this requirement, should I create Custom Delivery Extension or Custom Rendering Extension? Becaue What I see in rsreportserver.config file, the Rendering Extension defined under <Extension></Extension> tag are available for File Based report subscriptions So is there any relationship between them? Please point me to right direction.

Load balancing and Custom Filters in WCF 4.0 Routing Services

Hi, Couild someone please guide me to various ways of achieving load balancing using Router Service. i tried seeing few Blogs and tried to understand the round robin concept and the custom filters conceptr. but i m not able to see any specific site which would guide me on various examples of custom filters .And round robin seems a bit complex. http://blogs.msdn.com/b/routingrules/archive/2010/04/14/load-balancing-at-the-routing-service.aspx The above link gave me some insight  . is there any othe way of achieving load balancing other than Round robin. I did go through the samples of Routing services in WCf training Kit Thanks

Custom Authentication migration question

A migration question... sorry if outdatedIn my student times I wrote an application in ASP.NET. Now I wish to upgrade the code to a later Framework versions but want to keep the database structure and old authentication.  Could anyone please send a link to a good article on how to make custom authentication in FrameWork 3.5? And a general question: is it better to move to the built-in authentication functionality? If yes then why? Many thanks

membership provider with custom login form problem / question

Hi all, I am using the .net membership provider, and I can get past the membership.validate user ok and into my secure page.   The problem I have is that when I reach the secured page, I have a login status control which isn't changing from login to logout.   Below is my login code:If Membership.ValidateUser(txtUsername.Text, txtPassword.Text) Then Response.Redirect("/auth/Default.aspx") If chkRememberMe.Checked Then FormsAuthentication.SetAuthCookie(txtUsername.Text, True) Else FormsAuthentication.SetAuthCookie(txtUsername.Text, False) End If Else lblLoginStatus.Text = "Oops! Login not found!" End If    Thanks in advance.

ASP.NET MVC2 Custom routing with wildcard or free text url


I have a requirement to add specific functionality to an asp.net mvc2 web site to provide addtional SEO capability, as follows:

The incoming URL is plain text, perhaps a containing a sentence as follows

"http://somesite.com/welcome-to-our-web-site" or "http://somesite.com/cool things/check-out-this-awesome-video"

In the MVC pipeline, I would like to take this URL, strip off the website name, look up the remaining portion in a database table and call an appropriate controller/view based on the content of the data in the table. All controllers will simply take a single parameter bieng the unique id from the lookup table. A different controller may be used depnding on different urls, but this must be derieved from the database.

If the url cannot be resolved a 404 error needs to be provided, if the url is found but obsolete then a 302 redirect needs to be provided.

Where the url is resolved it must be retained in the browser address bar.

I have had a look at the routing model, and custom routing and can't quite work out how to do it using these, as the controller would not be predefined, based on a simple route. I am also unsure of what to do to provide 404, 302 back to the headers also. Perhpas I need a custom httpmodule or similar but going there went beyond my understanding.

This must be possible someho

Mapping custom values and columns to destination table **Newb question**



I am copying data from one source to destination SQL CE table using the data flow task. I have two extra requirements which I am not sure how to achieve.

1.)  One source column needs to be mapped to two destination columns. In the column mapping dropdown the column name disappears after mapping it to one destination column.

2) some custom values for columns need to be added, which are not present in source. For e.g. a default value for some destination columns which is not present.

Any pointers would be extremely appreciated. Thanks,

Ganesh Ranganathan
[Please mark the post as answer if it answers your question]

Custom Error Page question


I create my own customize error page. The code fragement for catch the eroor as following:

HttpCompileException _ccExp = null;
string _expType = "RunTime Error...";
Exception _lastError = Server.GetLastError();

// Get the Stack Frame
if (_lastError is HttpUnhandledException && _lastError.InnerException != null) _lastError = _lastError.InnerException;
//StackTrace stack = new StackTrace(_lastError.GetBaseException(), true);
StackTrace stack = new StackTrace(_lastError, true);
for (int i = 0; i < stack.FrameCount; i++)
	if (!String.IsNullOrEmpty(stack.GetFrame(i).GetFileName())) {
		_frame = stack.GetFrame(i);
if (_frame == null) _frame = stack.GetFrame(0);

// Get file name
string _fileName = _frame.GetFileName();

I try get the .aspx file in the last line, "string _fileName = _frame.GetFileName();".
Why I got a url-formed file name such as "http://server/Work/SomeOne.aspx", sometimes,
and other time, I got a physical path such as "D:\websites\MySite\wwwroot\Work\SomeOne.aspx" ?


Newbie custom web control question


I'm trying to create an .ascx control from scratch for the first time, and running into issues.  I get the following error when I run my code.  Many thanks for any guidance!


Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Content ('</MyCustomControls:TestUserControl>
</asp:Content>') does not match any properties within a 'CustomUserControl.TestUserControl', make sure it is well-formed.

Source Error:

Line 7:  <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
Line 8:      <p>
Line 9:      <CustomControls:TestUserControl Name="MyControl" runat=server></MyCustomControls:TestUserControl>
Line 10:     </p>
Line 11: </asp:Content>

Source File: /default.aspx    Li

Question about a custom InfoPath 2003 Query


I have searched the web and youtube but cannot find anything. I have published a InfoPath form to a SharePoint list, and created a "Receive" connection. I need help creating the search to pull data using 2 dropdown boxes and a Query button. Here are the steps. (this is NOT a web form, just a standard form)

1. The user will choose Q1, Q2, Q3 or Q4 from the 1st dropdown box.

2. Then choose Submitted, Review, or Stage3 from the 2nd dropdown box. 

3. Then click the Query button. 

4. Then I want the results to be displayed in a repeating table with controls. (which I already have setup)

Any help to build the query logic would be greatly appreciated! 

Thank you for your time!''


Custom Routing Scenario in MVC



How can I achieve this url "http://localhost:85312/Products/Detail/12/Category/25/Page/2" in Global.asax?

The 'Detail/12/Category/25' is dynamically created, it could be 'Detail/12/Category/25/List/33' or 'Detail/12/Category/25/List/33/Menu/2'
while the 'Page/2' retains at the end part of every url.

I couldn't get it to map in my Global.asax Sad

        routes.MapRoute( _
            "Default", _
            "Products/{*pathInfo}/Page/{page}", _
            New With {.controller = "Products", .action = "Index", .id = UrlParameter.Optional} _

Thank You,


looking out Versioning WF4 services using custom filters in Routing service


Happen to see Matt Snider's post on a thread at http:/ /social.msdn.microsoft.com/Forums/en/wfprerelease/thread/0fa38041-f85b-4882-b350-77eaf6998c4a
In this he has given a list of possible solutions for implementing workflow service versioning. The last solution that he explains is . . .

Utilizing constructed correlation data in order to distinguish between v1 and v2 conversations (a client should be tied to a given version for the length of a conversation).

This is the same solution that I wanted to implement in my system, But I have no idea on how to implement it.

Please assist me to implement the same.

URGENT- Unable to set Custom HEADER in WCF Routing Service


Hi All, 

I am having the below setup. 

WCF Client <===TCP Binding==> WCF Routing Service <==== basicHTTPBinding====> WCF Service 

My requirement is need to add the SessionID in the Cookie in the WCF Routing service. 


I am using the  IClientMessageInspector in Routing service as below and adding the HttpRequestMessageProperty properly. Before returning i check that cookie is added.

However, at the WCF server side i seen that Message.Properties is not received ( b

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

Writing custom MembershipProvider

ASP.NET Membership mechanism allows to use the build-in server tables to store and retrieve user data. By default, this mechanism can only be used with SQL Server database to which Microsoft provides suitable MembershipProvider class.
Inheriting from this abstract class, developer can use his own table(-es) from any database and use any database engine other than SQL Server, like Oracle, DB2 etc.

Routing for Web Forms in ASP.NET 4.0

posted a prototype demonstrating how one could use Routing within Web Forms. This is something you can do today with ASP.NET 3.5 SP1, because of the work we did to separate Routing from ASP.NET MVC. I would have liked to include Web Form Routing as part of the Routing feature when we were working on SP1, but we didn't have the time to do so in a robust manner before SP1 was locked down.

What's new in ASP.NET 4.0 - Part II - Routing in Webforms

This post covers one such feature which is Routing in Webforms. Although Routing was available even in .NET 3.5 SP1, (check this excellent post by Phil Haack on implementing Routing in ASP.NET 3.5 with .NET 3.5 SP1), it was kind of less known. Also the plumbing work was too much for getting it implemented.
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