Web.Routing For The Website Root Or Homepage?

Apr 1, 2010

I am doing some work with Web.Routing, using it to have friendly urls and nice Rest like interfaces to a site that is essentially rendered by a single IHttpHandler. There are no webforms, the handler generates all the html/json and writes it as part of process request.

This works well for things like /Sites/Accounting for example, but I can't get it to work for the site root, i.e. '/'.

I have tried registering a route with an empty string, with 'default.aspx' (which is the empty aspx file I keep in my root folder to play nice with cassini and iis). I set RouteExistingFiles to false explicitly, but whatever I do when hitting the root url it still opens default.axpx, which has no code it inherits from, and contains a simple h1 tag to show that I've hit it.

I don't want to change the default file to redirect to a desired route, I just want the equivalent of a 'default' route that is applied when no other routes are found, similar to MVC.

For reference, the previous version of the site didn't use Web.Routing, but had a handler referenced in the web.config that was perfectly capable of intercepting requests for the root or default.aspx.

Specs: ASP.NET 3.5sp1, C#, no webforms, MVC or openrasta. Plain old IHttpHandlers.

View 1 Replies


Similar Messages:

VS 2010 - Homepage Won't Load Unless Specifically Type Filename Into Root Of Website

Oct 11, 2012

I'm not sure what I did to cause this but my website homepage won't load unless I specifically type the filename into the root of the website - i.e. URL....works but URL... doesn't. It could be something I changed in the web.config or the project properties.

View 2 Replies

Web Forms :: ScriptManager Uses Website - Root Instead Of Application Root Directory

Jan 27, 2010

I ran into the following issue when trying to run a test website on IIS 7.5 (Windows Server 2008 R2 DatacenterEdition). The web-app is configured to run with framework version 3.5 in a .Net 2.0 app pool. Also the framework 4.0 beta 2 is installed on the server. The application named 'TestPfade' is located under the website's root named 'Default'. It is not only a virtual directory but defined as an application. The folder structure looks like this: The markup of the sole document reads as follows:

[Code]....

When viewed in a browser the image gets shown because the given relative path is correctly resolved to 'images/Lighthouse.jpg' but the paths to the ajax-framework resources also include the application's root folder and therefor aren't found: 'src="/TestPfade/WebResource.axd?d=1bX...' Here is the complete html-source generated:

[Code]....

View 9 Replies

C# - Webform Routing Home Page In A Folder Like Mvc Rather Than Root Of Site

Aug 18, 2010

I've got webform routing setup on my asp.net webforms 3.5sp1 project. I would like to have the files for the site in a directory called content including the home page as I would like to run multiple sites using the same system. In MVC there is a blank default page and the home page is in a folder called home. I can't seem to replicate this behaviour using web form routing but would like to. The blank page is always hit first. the route handler is hit second - it recognises that the request is for the home page and sets up the routing page but is not used. the route handler code is simple:

public string VirtualPath { get; private set; }
public IHttpHandler GetHttpHandler(RequestContext
requestContext)
{
string file = requestContext.RouteData.GetRequiredString("File");
string id = requestContext.RouteData.GetRequiredString("Id");
string queryString = "?menuid=" + id;
VirtualPath = "~/" + file;
HttpContext.Current.RewritePath(
string.Concat(
VirtualPath,
queryString));
var page = BuildManager.CreateInstanceFromVirtualPath
(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
}
Is there anyway I can do this?
Update
Here is my global.asax route code:
public static void RegisterRoutes(RouteCollection routes)
{
Domain.RepositoryFactory repo = new RepositoryFactory();
foreach (var x in repo.MenuRepository.GetAllEnabledGetMenus())
{
if (string.IsNullOrEmpty(x.Url))
{
//add default
System.Web.Routing.RouteTable.Routes.Add(
new Route("Default.aspx",
new RouteValueDictionary(new { File = x.FileName,
Id = x.Id.ToString() }),
new CoreRouteHandler()));
}
else
{
string url = x.Url;
if(x.Url.StartsWith("/"))
{
url = url.Remove(0, 1);
}
System.Web.Routing.RouteTable.Routes.Add(
new System.Web.Routing.Route(url,
new RouteValueDictionary(new {File = x.FileName,
Id = x.Id.ToString()}),
new CoreRouteHandler()));
}
}
}

View 2 Replies

MVC :: Default HomePage In Combined WebForms Website Not Working

Feb 25, 2010

We are starting to add some MVC pages to our exsiting WebForms website. When people type in[URL] they get a 404. If they type in[URL] then it works.

We are running Windows Server 2008 R2 with IIS 7.5. The default document is set in IIS.

The 404s started when we introduced MVC, so routing must be the guilty party here.

Here is my Global.aspx.cs.RegisterRoutes method

[code]....

View 6 Replies

How To Change Website Root

Jan 19, 2011

I am URL routing myself.

Main project only contain the URL routing code.

Different websites are placed on approot.

e.g: I have deployed VS2010 test-default-website at approot/webTest/.

I am trying to opening [URL] from browser.

For that URL request, I am serving page using PageParser.GetCompiledPageInstance(), as follows:

In URL route request handler,

return PageParser.GetCompiledPageInstance("webTest/Account/Login.aspx", HttpContext.Current.Server.MapPath("webTest/Account/Login.aspx"),
HttpContext.Current);

I am getting following exception:

The file '/Account/webTest/Account/Login.aspx' does not exist.

PageParser.GetCompiledPageInstance is automatically appending '/Account' before the actual address, thus unable to find it.

How can I make it not to append '/Account' ?

View 1 Replies

Running A Website From The Root?

Jan 9, 2010

I have an ASP.net Website. the project' content is in a folder called MyWebSite. When I run my application from Visual Web developer 2008, the browser displays the following address in the address bar: http: // localhost/ MyWebSite /Default.aspx

I want to be able to run my Website from the following address:

http://localhost/

View 3 Replies

IIS 6 Website Root Vs Application?

Mar 8, 2011

IIS 6
ASP.NET 3.5 (C#.NET)

We are having an issue where the same set of files behave differently depending on if it is a root IIS website versus an application under an IIS website. The urls produced using ResolveUrl() are different - i.e.:

<a href="<%=ResolveUrl("~/contact.aspx") %>">Contact Us</a>

As the root website, it produces: http://contact.aspx

As an application under a website, it produces: http://domainname.org/DSC/contact.aspx

Both are utilizing the same files. The first example is its own website, the second is a virtual directory made into an application (titled DSC). Both also use the same application pool, and same configuration, document and security settings (I made sure all the settings were the same in IIS between both).

Everything that has been researched indicates ResolveUrl() does refer to the IIS application that the webpage is under. I have also read several places that even if the information isnt completed in IIS (in this case it is), a root website is considered an application. Therefore, it should produce the appropriate web address, but isnt.

View 1 Replies

Configuration :: Iis 7 - How To Host The Website At The Root

Jul 9, 2010

I've followed this link [URL] to configure my application on iis7.

- I've published it

- create a folder in inetpubwwwrootMyApp

- I've created my virtual directory to point on MyApp

but then to log on it, I need to point on http:\localhostMyApp but i would like to point on http:\localhost

View 1 Replies

C# - How To Select A Folder Relative To Root In Website

Jul 29, 2010

I am trying to select all the files from a folder in my website and store them in a collection. The problem is that when I run the website it is not selecting the folder in my website:

This is the basic structure: [Root Folder] --> [FilesFolder]

Here is the code I am using:

DirectoryInfo dir = new DirectoryInfo("FilesFolder");

But it is showing this at runtime as the location of the folder:

C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0FileUploads

Is there a way to select the folder relative to the root of the website?

I am using C# with ASP.NET 3.5

View 2 Replies

Web Forms :: Find The Root Path Of Website?

Jan 3, 2010

I want to find the root path of my asp.net website.

Im using Request.PhysicalApplicationPath right now which looks like this:

F:CasperMy DropboxDotNetPortfolioV2 (Which is good)

But if I go to a folder it will be:

F:CasperMy DropboxDotNetPortfolioV2FolderName (Not good)

I just want the root.

View 2 Replies

C# - Saving Files In The Root Website Directory In Apache

Jul 16, 2010

I have an ASP.NET application running on Apache server with mod_mono. If I have a folder called "temp" located in the website's root directory and run the following code

System.IO.TextWriter tw = new System.IO.StreamWriter("temp/test.txt");
tw.WriteLine(DateTime.Now);
tw.Close();

it saves test.txt in C:Program FilesMono-2.6.4in emp on the server. If I add a slash to the directory name like this: System.IO.TextWriter tw = new System.IO.StreamWriter("/temp/test.txt"); It saves it to C:/temp. Both do not do what I want. How do I get the code to save the file to the temp folder inside my website's root directory? Is this a mod_mono issue or something to do with Apache? I have tried adding this line to httpd.conf Alias /temp "C:/Path_to_root_folder/temp" without any luck. I shouldn't have to use alias if the temp folder is within the root directory, correct? In my development environment which uses XSP as the web server everything works as expected. It is only a problem when running on Apache.

View 1 Replies

Addressing From The Root Directory Of Website In Action Script

Oct 30, 2010

I have a flash banner in my website and it has some navigation links on it. Because I have several different folders in my website I need address them from the root. At the moment i use getUrl like this: getURL("ArticleList/Default.aspx"); But it doesn't work .

View 2 Replies

Configuration :: Access To Files In Website Root Via Subdomain

Jun 9, 2010

folders in my website root are

a
b
c

I have subdomain "s1" which points to "a" folder. I want to know how could I access to files stored in "b" folder form subdomain "s1". My issue is that files I have some html content which saved in DB Records and their path are base on webroot i.e. "<img src="/b/movie1.avi" /> .Could any one tell me how I could show these files via subdomain "s1"

View 1 Replies

Web Forms :: No Default.aspx In The Root Of Website Project?

May 27, 2010

i have a website project. i have 2 folders within default.aspx. in the root i have no default.aspx.

How can i redirect users when they are in Role "Folder1" to the ../Folder1/default.aspx
and user in Role "Folder2" to the .../Folder2/default.aspx

View 2 Replies

Default Behaviour Is Sending The User To The Website Root?

Sep 16, 2010

Is it possible to control the behaviour of ASP.NET when the Session has expired? It seems that the default behaviour is sending the user to the website root. The desired effect would be to send the user to a custom "Session Expired" page.To clarify, it's the SessionState that's expiring (set the timeout to 1 minute to quickly test it):

<sessionState mode="InProc" timeout="1"></sessionState>

The authentication cookie timeout is way higher, to avoid any mix-up:

<authentication mode="Forms">
<forms loginUrl="SessionExpired.aspx" slidingExpiration="true" name=".ttpASPXAUTH" timeout="58" protection="All"></forms>
</authentication>

View 2 Replies

Data Controls :: Image Folder Outside Root Website

Dec 27, 2011

I had a look at Displaying images that are stored outside the Website Root Folder

View 1 Replies

Web Forms :: Access Text File In Website Root Folder?

May 27, 2010

In Visual Studio I added a text file Example.txt to the root folder of my web site (where Default.aspx exists).

Later in C# code I reference this file :

string text = File.ReadAllText("~/Example.txt"); // also tried without the ~/

During runtime, both debug and non-debug, I get an error at this line of code:

C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0Example.txt'.

So, how should I reference this file?

View 2 Replies

Data Controls :: Display Images Saved In Folder Outside Website Root Directory In GridView

May 7, 2015

I want to display images from outside the domain url. How to achieve this.For Example my domain is www.test.co.in

My folder structure is

--Documents/Images (that has images)
---test(root folder that has project files)

View 1 Replies

Virtual Directory Root Vs Default Web Site Root

Feb 11, 2011

I am using iis 5.1 in which we have only only one default website, I have two projects v2 and v3 my website points to v2 projects and have some folders images, styles etc now i have a virtual directory under this website that is hosting project v3 and having the same folder hierarchy as v2 in the home page of the both projects i have img src="imagesedlogo.gif" alt="logo"/> but this shows the same image that is in the v2 directory, How can i show different images for both projects. using "" get the root of the web site but how can i get the root of virtual directory under that website

View 2 Replies

Request The Root Default.aspx Without Specifying It In The Url For Your Root Application?

Sep 17, 2010

How can you request the root default.aspx without specifying it in the url for your root application?e.g. ttp://localhost/MyApp/ instead of http://localhost/MyApp/Default.aspxshould be able to do bothI'm not sure if this is a setting in IIS 7.5 for the application or what.

View 3 Replies

How To Implement Url Routing For A Website Which Is One Year Old

Apr 2, 2010

Is it advisable to implement url routing for an asp.net(webforms) website which is one year old... What are the factors to be considered before implementing....

Edit: It is a web based product website developed my company and users should pay for using it...

View 2 Replies

Why Necessary To Create Virtual Directory In IIS When Website Content Is Placed In IIS Root Directory

Feb 13, 2010

As virutal directory points to physical path of the application, so if the IIS root directory is C:inetpubwwwroot and the application is stored at D:websites, than we need to create a virtual directory but if the application content is placed at C:inetpubwwwroot, then why still need to create virtual directory.

View 3 Replies

Web Forms :: Routing 4.0 / Deploy Website On A Remote Server ( Integrated Pipeline ) It Returns With 404 Error?

Sep 8, 2010

When I run my website on local server asp.net routing works very well, but when I deploy it on a remote server ( asp 4.0 integrated pipeline ) it always returns with 404 error.

My url route is very simple, a stored procedure gets image's id and then displays it.

Global.asax:

[Code]....

Default.cs:

[Code]....

View 6 Replies

Web Forms :: Web.Routing Doesn't Work On Server On IIS Routing

Jul 20, 2010

I tried everything I could find, but still does not work on IIS routing.

View 2 Replies







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