.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

Problem with default routing

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :ASP.Net
Hi, I am Ashish. I have developed an ASP.NET web application using MVC 1.0. I have taken a view named TaskUI and Controller TMController. I have chosen my UI page is as default page, and accordingly I changed Default Rout as given bellow: routes.MapRoute( "TaskUI",// Route name "{controller}/{action}/{id}"// URL with parameters new{ controller = "TM", action = "CreateTask", id = "" } // Parameter defaults); It is working great... My UI page contains a textbox which is tagged with a javascript onChange function <%=Html.TextBox("TaskId", ViewData.Model.Task.TaskId, new { size = 10, onChange = "GetTaskInfo1()", onkeypress = "InputOnlyNumber(event)" })%> When I input a value on the textbox and press the tab the javascript function is called which isfunction GetTaskInfo1() { var vCalleeVar1 = document.getElementById('TaskId').value; if (vCalleeVar1 != undefined && vCalleeVar1 != null) { location.reload("GetTaskInfo?pTaskId=" + vCalleeVar1); return true; } else return false; } Now the problem is the URL that gets LocalHost.../GetTaskInfo?pTaskId=123, whether it should be LocalHost.../TM/GetTaskInfo?pTaskId=123, because the action "GetTaskI

View Complete Post

More Related Resource Links

Problem upgrading to MVC3 - System.Web.Routing



I'm trying to upgrade to .NET 4 and MVC 3.

When trying to compile my project, I get the error:

Error 1 The type or namespace name 'Routing' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) C:\Users\spencer\Desktop\weblauncher\Common\MVCConfig.cs 4 18 Common

The type or namespace name 'Routing' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

I do have the System.Web.Routing in my references for the project.

BUT - when I try to view System.Web.Routing in the OBJECT BROWSER, nothing is inside!  The System.Web.Routing namespace is not in there - the entire thing is empty!  Could it that the dll is corrupted?  I tried to reinstall the .NET 4 and MVC 3 stuff, but its still empty!

The dll is coming from here:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web.Routing.dll

and the runti

Strange URL Routing Problem, participially working


I am setting up URL Routing on my existing project. I am not using mvc.

The routing only working like this: http://www.example.com/sdevil.m

not working with single word like this: http://www.example.com/sdevil

I am getting error message:The resource cannot be found.

Looks like when I using single word, application think that is folder?

How can i fix this? Thank you for any helps.

Routing, Paging and Area problem. Please, anyone?

Hello,On a pager I use on my MVC site I create the page links as follows: private String GetPageLink(Int32 number, String text) { RouteValueDictionary link = new RouteValueDictionary(_values); link.Add("page", number); VirtualPathData path = RouteTable.Routes.GetVirtualPath(_context.RequestContext, link); return path == null ? null : String.Format("<a href=\"{0}\">{1}</a>", path.VirtualPath, text); } // GetPageLink On a MVC 2 web site I have an area named CMS.For example, on "cms/article/list" the pager works fine.However, on my root views, for example in "article/index" the page 1 link become:  http://localhost:7422/cms/article?page=9It should be just:  http://localhost:7422/article?page=9o On my Global.Asax I have the following:  routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional }, new String[] { "PrjMvc.Presentation.Controllers" }); routes.MapRoute("CMS_Area", "{area}/{controller}/{action}/{id}", new { area = "CMS", controller = "Home", action = "Index", id = UrlParameter.Optional });Any idea how to fix this?I have been going around with this and I can't find a

Problem Saving Files to A Sharepoint 2010 Site from Office 2010: Saves locally by default rather tha

Hi we are starting to use sharepoint 2010 / word 2010 and have found an interesting bug/problem. Sometimes when a user tries to save a file (by clicking on the save button in the quick access toolbar for word 2010) the save dialog comes up with the users local "Documents" folder as the path (not the correct sharepoint path where the document should be saved).  (I should say that we are creating the file from sharepoint by using a toolbar on the document library, with the new button)  We are using a content type and a template attached to the document library when we create the file.  This is really annoying because the user might not notice that the document is saving locally and not to sharepoint.  I have found a strange workaround which involves clicking the [File] tab on the ribbon in word 2010, then clicking "Save and Send" and then clicking the save button again.  At this point word 2010 seems to "remember" that it is trying to save document to sharepoint and shows the sharepoint document library. This is a real nuisance which could lead to documents being lost/misfiled if people don't realize that this is happening.  Can anyone help me? Thanks Kevin krd

Problem building with InternalsVisibleTo with projects having workflows with default value set to ar

To reproduce : - Create a C# Class library project with this class :   namespace ClassLibrary1 { internal class Class1 {} } - Create a new C# Test Project and create this unit test class : using ClassLibrary1; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestProject1 { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1 () { // this is ok : Class1 class1 = new Class1 (); } // Compile time problem : // Error 1 'ClassLibrary1.Class1' est inaccessible en raison de son niveau de protection // Error 4 Accessibilité incohérente : le type de paramètre 'ClassLibrary1.Class1' est moins accessible que la méthode 'TestProject1.UnitTest1.TestA(ClassLibrary1.Class1)' private static void TestA (ClassLibrary1.Class1 a) { } // Compile time problem : // Error 1 'ClassLibrary1.Class1' est inaccessible en raison de son niveau de protection // Error 2 Accessibilité incohérente : la classe de base 'ClassLibrary1.Class1' est moins accessible que la classe 'TestProject1.UnitTest1.Derived' internal class Derived : Class1 { } } } - Add a InternalsVisibleTo atribute into the class library project : [assembly:InternalsVisibleTo ("TestProject1")] - Add a new "Workflow\Activity"

Seeking Routing help. Problem with ActionLink.

 I have 2 action links:
<%: Html.ActionLink("Home", "Index", new { area = "", controller = "Home" })%>
<%: Html.ActionLink("About", "About", new { area = "", controller = "Home" })%>

They are rendering as: <a href="/">Home</a> <a href="//Home/About">About</a>

Which is the problem. The // is causing the browser to go to hxxp://Home/About Other ActionLinks are working fine such as.

<%= Html.ActionLink("Log In", "LogOn", new { area = "Authenticate", controller = "Main" })%>
<%= Html.ActionLink("Register", "Register", new { area = "Authenticate", controller = "Main" })%>

They are rendering as: <a href="/Authenticate">Log In</a> <a href="/Authenticate/Register">

Asp.Net Routing Css And Javascript Reference Problem


Hi All!

I have problem with url routing. I'm using Asp.Net theme in my project. My theme is messing up. I couldn't figure out how could i ignore the css and js files.

Web.Config theme reference;

<pages theme="Default" styleSheetTheme="Default" ></pages>

I've tried;


routes.RouteExistingFiles = false;//assume routes as my routecollection

and this;

            routes.Ignore("{*alljs}", new { alljs= @".*\.js(/.*)?" });
            routes.Ignore("{*allcss}", new { allcss= @".*\.css(/.*)?" });

and this;


but still doesn't work. Some of my friends told me to use ResolveClientUrl but i can't figure out how to reference it(because asp.net theme writes it for me already).

I need help. Thanks.

p.s sorry for my bad english

problem with connecting to local SQL Server 2008 default instance using windows authentication




I have a user getting some problem with connecting to local SQL Server 2008 default instance using windows authentication with a user which has sysadmin role and is owner of each existing database:

2010-09-28 15:40:35.04 Logon       Error: 18456, Severity: 14, State: 11.


2010-09-28 15:40:35.04 Logon       Login failed for user 'IIS APPPOOL\RoomViewSEWebClient'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT:]



This us

Re-routing the default URL


Currently the URL “intranet.sph.uic.edu” is going to the My sites default information,  We have turned off my sites and now that url goes to an error page.


The question I have is how to adjust the “intranet.sph.uic.edu” URL to go to the site I have created located at “intranet.sph.uic.edu/sites/intranet”???



Problem in Routing WCF Service call from another WCF Service

Dear All,
           I have few WCF Services hosted on a remote machine which access my remote DB.
I call the services from my windows application and everything works like a charm.

           Now I want to make the above service calls from machines which will not have internet.
But they will be on LAN where atleast one PC will have a active internet connection.
So I created another WCF service which is hosted on a Windows service on the internet enabled machine. I've added all the service referance in the new service and any service withoute any parameters work fine.

           But when I try to send any data as parameter I get error

"There was an error while trying to serialize parameter http://tempuri.org/:obj. The InnerException message was 'Type 'Consume_Win_WPF_Service.LOginService.ClsMessage' with data contract name 'ClsMessage:http://schemas.datacontract.org/2004/07/LoginService' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details."

Can anyone tell me what steps I should impliment to en

Dynamic routing problem when invoking site from remote host.



I have problem described under following link: mvcrouting

Can someone give me some clues how to deal with that ?


Default (but overrideable) date in DetailsView problem


I'm using a DetailsView control in Insert Mode (GridView for editing). I want to have today's date default into my date field, but the date has to be able to be overridden by the user.  

I can bind it to the database element (1) OR I can default today's date (1) , but seeming not both. What am I doing wrong?

(1) - Bind to database element

<asp:TemplateField HeaderText="Date" SortExpression="EmployeeTimeDate">


      <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EmployeeTimeDate") %>'></asp:TextBox>



      <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("EmployeeTimeDate") %>'></asp:TextBox>



      <asp:Label ID="Label5" runat="server" Text='<%# Bind("EmployeeTimeDate", "{0:d}") %>'></asp:Label>



Problem with default list form


Hi, I was following this article to create custom forms for my content types in a list but I am not able to get that each content type use his custom form.

The form set as default is used no matter what content type item I am creating. there is any kind of problem or setting that I am missing?

If I understand well the below text extracted form the article this is posible, but how?

 "Note   Every list or library can be configured to allow multiple content types, which then appear in this menu. You can use a distinct set of custom list forms for each content type available for a list or library. For example, if your list has both a Press Releases content type and an Industry News content type, you can create and use two separate sets of custom list forms, one for each of the two content types. The advantage to using a separate set of custom list forms for each content type is that then each custom list form is designed to display only the fields that are appropriate for that content type. Find more information about content type

4.0 Routing problem with different directories



I am working on a website which contains several directories and master pages, i am facing a problem with routing.
Normally routing works great. I hope you can help me with this issue

main dir wwwroot which contains a global,asax seen below
NL/NewsArticle.aspx file exists , however below url returns a 404.


any help would be appreciated, regards!

void RegisterRoutes(RouteCollection routes)    


routes.MapPageRoute("News", "NL/News/{title}/{newsid}", "~/NL/NewsArticle.aspx");    


void Application_Start(object sender, EventArgs e)    

{        // Code that runs on application startup        



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.NET 4.0: WebForm Routing (quick n dirty version)

One of the things we're adding in ASP.NET 4.0 is built-in support for using Routing together with WebForms. Now, I'm totally aware that this is possible to do already and that a number of people have posted ways of doing this with the Web Routing feature which shipped with ASP.NET 3.5 SP1. We're just adding some features to make it easier to do
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