.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

Html.ActionLink displayes unwanted virtual directory routing

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
My hosting provider has ASP.NET 3.5 and I'm using MVC 2.0. I have two domains on my account, http://www.domain1.com, and http://www.domain2.com, each has it's own virtual directory off of the root: / /domainone /domaintwo   Their routing commands for their httpd.ini rerouts http://www.domain1.com to http://www.domain1.com/domainone   If I type in the address bar http://www.domain1/Home/About, it works properly. The Problem My website links created using Html.ActionLink add the virtual directory. If you mouse over the About link in your standard MVC2.0 webapp, it displays as follows: http://www.domain1.com/domainone/Home/AboutAll of my testing and setup on my development machine doesn't have this virtual directory, and in the past my webhost didn't have this issue in the path. But since the move to their 'new' shared hosting platform, this is now what I'm having to deal with. How do I setup my ASP.NET MVC 2.0 web application to remove the unwanted virtual directory name from the path in my ActionLink controls? For example, when I mouse over the About link, I want the path to be http://www.domain1/Home/About ..or how can I add a new route handler to strip the virtual directory path from http://www.domain1/domainone/Home/About.   When I mouse over the Log On button on my logon page, the partial url domainone/Account/Lo

View Complete Post

More Related Resource Links

Difference Btw Website vs Web application and Virtual directory in IIS 7


May i know what is the Differenc that they actually make in IIS7 .

Please tell me at a low level as i am still a novice in Asp.Net


Thanks in Advance.


Conditional styles for selected Html.ActionLink


Hi, I am trying to add an item selected class to an Html.ActionLink, I am very new to MVC so its all a bit confusing.

So far i have each of my ActionLinks lookins like this

<li><%: Html.ActionLink("Home", "Index", "Home", new { @class = ViewData["current"] == "Home" ? "selected" : "" })%></li>

And in the controller i have

public ActionResult Index() {
            ViewData.Add("current", "Home");
            return View();

Can any one tell where i am going wrong because the links now fail to respond, basically it isn't checking the condition == Home and if it is then its failing because it doesn't get to the controller.

Any ideas would be appreciated


send credentials for virtual directory through application

Hi All,Please let me know that how to send credentials for virtual directory through application.Thanking You...

Pass virtual directory credentials through application

Hi All,We have created a website and for the secured files created a virtual directory and in virtual directory properties we selected Application-user(pass through authentication).If any user directly browse the files link then the browser prompts a screen for virtual directory credentials.Here my requirement is i need to send the virtual directory credentials through the application.Please let me know.Thanking You..

Redirecting default.aspx to root virtual directory

I have a simple ASP.NET 3.5 application running under IIS7 under a virtual directory. So the URL of my app is like http://site.com/app. I want to 301-redirect the request to site.com/app/default.aspx to site.com/app for better SEO. I have to do this redirect through code only, not by any IIS settings. I am unable to do so via code mentioned in this article:http://www.4guysfromrolla.com/articles/072810-1.aspxThe code:if (request.RawUrl.Equals("/default.aspx")) { newUrl = string.Format("{0}://{1}{2}", request.Url.Scheme, request.Url.Authority, request.RawUrl.Remove(request.RawUrl.LastIndexOf("/default.aspx", StringComparison.OrdinalIgnoreCase))); context.Response.Status = "301 moved permanently"; context.Response.AddHeader("Location", newUrl); } seems to go into an infinite loop when the application is under a virtual directory. the request.RawUrl property always returns "/default.aspx" even after a 301 redirect causing the infinite loop. How can I fix this issuhttp://forums.asp.net/AddPost.aspx?ForumID=27e?

javascript web service in different virtual directory?

Hi, I've searched far and wide, but can't find out why this is happening. I have a clientside javascript ajax call into a web service that works fine if both the service and the calling page are in the same directory. If I try to move the web service to another virtual directory, I get this: Exception type: InvalidOperationException Exception message: Request format is unrecognized for URL unexpectedly ending in '/js'. Here are the relevant code tidbits for the separate directories attempt. Thanks for any help! aspx file:<div> <form id="form1" runat="server"> <asp:ScriptManager runat="server" ID="scriptManagerId"> <Scripts> <asp:ScriptReference Path="CallYahooQuotesServiceMethods.js" /> </Scripts> <Services> <asp:ServiceReference Path="/quotesservice/YahooQuotesService.asmx" /> <--- this works if remove /quotesservice/ and service is in same dir </Services> </asp:ScriptManager> </form> </div> <div>  <input type="button" value="Client" id="Button2" onclick="GetQuotes(ticker

Virtual Directory in VS

Hello,I'm using VS to produce my website.In IIS, this website has one virtual directory mapped on another physical directory on the disk.How can I include this directory in my VS project ?Website structure://physical_dir1/physical_dir2/virtual_dirDisk structure:c:\www\root\c:\www\root\physical_dir1c:\www\root\physical_dir2c:\anotherPath\ pathToVirtualDirAs my .csproj file is in c:\www\root, VS can't "see" the virtualdirMy question is not how to create the virtual dir in IIS, it's already done and all is ok. My question is how to include this dir in my projet in VSMany thanks for your help

Authentication with a UNC Virtual Directory.

I'm using IIS7.5 and Windows Authentication through an ISA server. I'm trying to migrate a classic ASP application to ASP.net.We have an internal file server with our department folders on and I'm trying to provide web based access to these. Previously I created a UNC virtual directory to the \\server\departments share, and because ASP classic ran in the context of the authenticated user they could only browse folders they had permission to.What security settings should I now be using for the Application Pool and what settings should I use on the Virtual Directory credentials to ensure security? I'd like the ASP.net page to run in the context of the logged in user, and when the code tries to display a sub-folder they don't have access to it should 'bomb out' as before.Thanks

Map a network share to a virtual directory path @ runtime

Hi Guys Have run into an interesting issue. We have an asp.net web application - we can deploy it over the internet, the secure intranet, local offline user laptops. On of the teams in our organization has a product by which they develop static html reports from the main database. Originally we developed a module in our app which is nothing more than an iframe. Since the html files were pushed under our application virtual directory we used to use java script to set the source of iframe to http://server/app/module/fileXXX.html   Now due to some deployment procedure changes and some security issues the html reports will be deployed on another network server and exposed through a share. Also the share will not have IIS so not virtual directory. So we can no longer set the iframe source through java script to a web file.   Is there any way i can @ runtime map a folder in my application virtual to the network share so that we can browse to these web files like before (Copying the files over from the share to my Virtual Directory is not a very elegant soln.)   Thanks Regards Siddharth

MaintainScrollPositionOnPostback = true is not working in IIS 6 with virtual directory is running A

Hi All, virtual directory is running ASP.NET 2.0.50727 Environment details: IIS 6 on Win Server 2003 The virtual directory is running ASP.NET 2.0.50727 I have set maintainScrollPositionOnPostBack="True" in the page directive Any ideas? Do I need to install any service packs? also the app is not working well with firefox in some scenarios

SSRS 2008- redirect to /Reports virtual directory?

We have just configured a new SQL Server Reporting Services 2008 server. So far, everything is going well, with the exception of one thing: we want anyone who hits the root of the webserver to be redirected to the /Reports virtual directory. So, if the user enters http://servername.domain.com/ it would redirect to http://servername.domain.com/reports. In SSRS 2005, it was easy to configure IIS to do this, but with SSRS 2008, I cannot figure out how to make this change. Help?

i cannot access iis virtual directory using http protocol..getting status code error 403

i am trying to connect to remote exchange using powershell..while using powershell session i get status error 403...i changed the settings in iis manager...i have set all the settings in the iis manager as said in the msdn support blogs...yet i get the same error when i access it in the client url and also in powershell of the client computer...if i cannot connect using powershell,can i connect using .net???somebody help me...i am beginner and i am stuck...

Asp.net MVC: How to call javascript function in Html.ActionLink

When I edit single recored in page, I use checkbox to get a selected row not every row with an actionlink element, but it seemed I cant make this way happen through calling javascript code(function GetSelectedRow() should return an id). Could anyone have a nice idea?<head runat="server"> <title>Index</title> <script type="text/javascript" language="javascript"> function GetSelectedRow() { var a = 0; var chkBoxes = document.getElementsByName("chkSelect"); var count = chkBoxes.length; for (var i = 0; i < count; i++) { if (chkBoxes[i].checked == true) a = chkBoxes[i].primaryKeyID; } return a; } </script> </head> <body> <div> <span style="width:20%"> <%: Html.ActionLink("Add", "Create")%> </span> <span> <%: Html.ActionLink("Edit", "Edit", new { id = GetSelectedRow()) %> </span> <span> <%: Html.ActionLink("Detial", "Details", new { id = GetSelectedRow() })%> </span> <span> <%: Html.ActionLink("Delete", "Delete", new { i

create and Edit Virtual directory through c#


Hi All,

I am working in a .net C# .In my application I have to create in the
IIS>local computer>Web Sites>Default Web Site - virtual directory

and also I want to be able to
change properties of this vitrual directory (All process of creation virtual directory in the IIS I want to do programmaticaly).

I had make a program in C# for create a Virtual Directory.But i didn't able to edit its property..

After this i have to implement all this program in .Net Remoting 0r WCF.So please guide its possible and how to i make it ,Please members or seniors help me.I'll wait for reply..

Warm Regards:-
    Gourav Vishnoi
   +91-9871157845 (M)

Response.TransmitFile virtual directory?


I can use Response.TransmitFile on my p.c. using VS2008  fine. But when I moved my code over to the server it won't work. Does the path have to be a virtual directory?


Lets assume you have 1 serverA with dir D:\ExcelReports and another serverB thats the webserver. So to transfer a file you would need something like Response.TransmitFile(D:\ExcelReports) ?

VWD2010, MVC2, Html.ActionLink and Application[]



This is my code:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    if (Request.IsAuthenticated) {
        <%:Application["Welcome"] %> <b><%: Page.User.Identity.Name %></b>!
        [ <%: Html.ActionLink(Application["LogOut"].ToString, "LogOff", "Account") %> ]
    else {
        [ <%: Html.ActionLink(Application["LogIn"].ToString, "LogOn", "Account") %> ]


What I want to do is pretty simple, I set appropriate values in the application array at the global.asax level and would then want to see those values be written in place of the default ones. That obviously does not happen or I wouldn't be writing here :-P


It gives out an error saying it doesn't find an correct overload for the method ActionLink(or something along these lines anyway).

Clearly, that's wrong :-P since I would expect it to display m

If-Else condition for ActionLink in Html Extension


In my code, I'm trying to write "if" condition in HTML.Helper instead of view.
Can you please tell me what mistake i'm doing?

Code on Controller

public static string IsSetup(this HtmlHelper helper, AModel aModel) 
string actionLink = string.Empty; 

 if (aModel.IsSetup) 
 { actionLink = "Html.ActionLink(\"" + "Continue for Setup\"" + "," + "\"Setup\"" + "," + "\"SetupController\") "; return actionLink; } 

 { actionLink = "Html.ActionLink(\"" + "Continue for Index\"" + "," + "\"Index\"" + "," + "\"SetupController\") "; 

 return actionLink; 


Code on View
        Please click to
        <%= Html.IsSetup(Model)%>
  // I'm expecting, <%= Html.ActionLink("Continue for Setup", "Setup", "SetupController") %>
  // but it renders as a TEXT like,  Please click to <%= Html.ActionLink("Continue for Setup", "Setup", "SetupController") %>

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