7 2702
Redirect away on the custom error page? ie Redirect to default.aspx on
load. Wouldn't this work ?
Okay, so are you Rewriting the path on begin request? I have done
something similar before. You could try rewriting the path again on the
begin request for the error page. Just check that they are going to the
error page, then if they are, read the aspxerrorpath from the query,
and rewrite the path using this value. that way you can have a nice
generic solution that you can use in your other sites. Are you by
chance developing a marketing system for your content so everything has
its own nice categorized folder path?
Charles
I am trying to build a system so that links are always to a nice folder path
instead of links that use query strings. (My site will have dynamically
generated paths).
I'm not sure how to rewrite the path, but I think I figured out how to solve
the problem.
Just to recap, www.mydomain.com/users/ is a real path in my project. www.mydomain.com/users/BobSmith/ is not (there's no "BobSmith" folder on my
server. If a user tries to browse to www.mydomain.comi/users/BobSmith, I
want that URL to stay displayed in their IE address bar, but I want the
actual content they see to be produced by the .aspx page at www.mydomain.com/users/Default.aspx.
I tried using the customErrors element in my web.config file to create a
redirect for 404 errors. It almost works - the user sees the content
produced by www.mydomain.com/users/Default.aspx, but the path in the IE
address bar is http://www.mydomain.com/users/Defaul...Users/BobJones.
I found that if instead of using the customErrors in my web.config file, I
just set up a custom error (for error 404) in IIS, then the URL displayed in
the user's browser is the desired, www.mydomain.com/users/BobSmith/, but the
content is created by www.mydomain.com/users/default.aspx. So the moral of
the story in this case seems to be to not use the web.config file to set up
custom error handling - I have to use IIS for this instead.
But, if there is a way to do what I want using the web.config file
customErrors element, I'd love to know how.
I found out the IIS approach has some extra restrictions... My 404 handler
page (the page that shows the content for "BobSmith" usese master pages, and
the ASP.NET theming. In the rendered page, all of the stylesheets and pics
are referred to with relative links. The links to the style sheets etc. are
rendered to HTML in relation to the actual location of my .aspx page. But
IE, expects to find these objects relative to the URL displayed in the
address bar. So, the URL the user is typing is: www.mydomain.com/users/BobSmith/
So, I have to put the error handling page in a subfolder of www.mydomain.com/users/ (I'm using www.mydomain.com/users/handler/Default.aspx). That way a relative link in
Default.aspx like, '../../stylesheet.css' goes to the same place when viewed
from the perspective of www.mydomain.com/users/handler/ or www.mydomain.com/users/BobSmith/.
I can't help but think though that there's an easier way.
With your mention of "rewriting" I had a new term to google on. And yes,
that is exactly what I am trying to do! After a lot of frustration, I have
settled on implementing an IHTTPModule to handle the 'fake' directories. I
have also found that by using the HttpContext.Rew ritePath overload like:
context.Rewrite Path("~/Users/Default.aspx?us erid=1", false);
I don't have the problems with relative links. (It's passing 'false' as the
second argument that does the trick). The documentation on this is pretty
slim so I have no idea why this works, but it just does.
Thats the trick. You could use Lutz Decompiler to see what the function
does. Just think of it as a redirect without sending the redirect
header to the client. You coudl get slick and database all of the paths
to content, and pass the id of the content to the new page. Good luck,
happy coding,
Charles This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Greg Burns |
last post by:
I am trying to write a global custom error page. I thought I would jot down
some of what I've learned so far...
At first I just used the default customErrors section with a defaultRedirect
tag, as such:
<customErrors defaultRedirect="error.aspx" mode="On" />
First thing I found out about this method, is that I didn't have access to
the exception object in my error.aspx page. So this page was going to be
|
by: John Lau |
last post by:
Hi,
I am looking at the MS KB Article 306355: HOW TO: Create Custom Error
Reporting Pages in ASP.NET by Using Visual C# .NET
This article describes how to redirect errors to a custom html error page.
All six steps in the article work just fine. Then at the end of the
article, there is a little comment about redirecting errors to an aspx page
(instead of an html page):
|
by: Mukund Patel |
last post by:
Hi friends,
I have implemented custom error handling at page level and application
level. If there is any syntax error in my aspx class file it will redirect
to error page when I run the page. But if any syntax error in my component
class (Code dir) it will not redirect to my custom error page. Is there any
way that will redirect to my custome error page in case of all type of
compile time error and runt time error anywhere in my...
|
by: Joe Rigley |
last post by:
Hi,
I have a custom class with a public method. I want to perform a
repose.redirect if an error occurs in the public method GetUserRoles.
Unfortunately, Visual Studio 2003 is throwing an error when I try to do
this.
I have imported the System.Web namespace and the same code works fine on a
..aspx page. Can you not perform response.redirects in a custom class that
is being called by another aspx page? Please help.
|
by: dee |
last post by:
Hi
In web.config I have to the following:
<configuration>
<system.web>
<customErrors defaultRedirect="error.htm" mode="On" />
</system.web>
</configuration>
| |
by: Laurie Dvorak |
last post by:
I'm working on converting a website that currently is all static HTML pages
to ASP.NET. Since people may have some of the HTML pages bookmarked, I
want to give them a meaningful error message page and point them to the new
pages. In my web.config file, I put the following:
<customErrors mode="On">
<error statusCode="404" redirect="404NotFound.aspx"/>
</customErrors>
This works fine if I try to request a non-existent file that has...
|
by: gilly3 |
last post by:
I'm coming across all kinds of frustration implementing custom errors in
ASP.NET 1.1.
First, 401 - Authorization Failed
My application uses Windows Integrated Authentication, and restricts
access to a single Windows User Group like this (in web.config):
<authorization>
<allow roles="Domain\UserGroup" />
|
by: c676228 |
last post by:
Hi everyone,
I have a piece of code in sales.aspx.vb like this:
Protected WithEvents Message As System.Web.UI.WebControls.Label
Try
...
ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr + "&ChartType=" +
drpChartType.SelectedItem.Value.ToLower() + "&Print=" +
printVersion.ToString()
...
Catch e As Exception
|
by: rote |
last post by:
I'm using ASP.NET 2.0 and i have copied and pasted the code below to my
Global.asax file but it desn't trap
the error
I want to trap the 401 access denied
void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |