[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 599
  • Last Modified:

ApplicationURL, AppicationRoot - will help me in the application redirect problem?

First of all - where do i set
ApplicationURL - This setting should be the URL of your web server, e.g. http://www.site.com
AppicationRoot - This setting is the virtual path to your installation of Application, e.g. /UltimateSurvey
what section of the the web.config? I couldnt find this anywhere.

Then what i really have is this :
I am trying to create a virtual Vanity URL so that someone can do
www.site.com/vanity/namename.aspx - which will map to
www.site.com/user.aspx?id=namename

I catch the request it fine int the Application_BeginRequest in my global.asax- but :
I can not redirect from one "application" to another (from /vanity back to default folder of my site). Yes i do use shared hosting and every folder has to be an application to compile aspx files and have global.asax.

The error shows to be :

erver Error in '/vanity' Application.
The virtual path '/user.aspx' maps to another application, which is not allowed.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The virtual path '/user.aspx' maps to another application, which is not allowed.

Source Error:

Line 13:             Context.RewritePath(strNewPath)
Line 15: End Sub


Source File: X:\vanity\global.asax    Line: 13

Stack Trace:

[HttpException (0x80004005): The virtual path '/user.aspx' maps to another application, which is not allowed.]
   System.Web.HttpContext.RewritePath(String path) +222
   ASP.Global_asax.Application_BeginRequest() in X:\vanity\global.asax:13

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess) +0
   System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess) +425
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +23
   System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +40
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication+IExecutionStep.Execute() +60
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87


Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Thanks for all the useful comments in advance,
A.M.
0
margant
Asked:
margant
  • 2
1 Solution
 
fruhjCommented:
You could use response.redirect

response.redirect(yoururl)

- Jack
0
 
rdivilbissCommented:
I am trying to create a virtual Vanity URL so that someone can do
www.site.com/vanity/namename.aspx - which will map to
www.site.com/user.aspx?id=namename

In order to do this, you will need a page for each vanity name in the vanity folder.  Each page will have exactly the same code, so that part is easy.

It will be much simpler to use classic asp for the redirect page, rather than .NET.

<%
Dim url, userid, server, redir

url = request.servervariables("SCRIPT_NAME")  ' like: /vanity/namenamet.asp
server = request.servervariables("SERVER_NAME")  ' like: www.site.com

if InStr(2, url, "/") > 0 then   ' find the second / and get the page name
     userid = Mid(url, InStr(2, url, "/")+1)
end if

if userid <> "" then
    userid = Left(userid, Length(userid)-4) ' strip the .asp
    redir = "http://" & server & "/user.aspx?ID=userid
    'response.redirect redir  <- uncomment for production
    response.write redir       <- comment out for production
end if
%>
0
 
margantAuthor Commented:
rdivilbiss - thats a may not be the best solution. In global asax there is a function APplication_BeginRequest that will help in redirecting instead of creating tons of useless pages and putting same code in them.
0
 
rdivilbissCommented:
Nice to know.  Thanks margant!!!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now