• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1356
  • Last Modified:

Global.GetApplicationPath

hi

can some one explain what is global.getApplicationPath...in asp.net....

how is it diff from Request.ApplicationPath or PhysicalApplicationPath

thank you
0
praneetha
Asked:
praneetha
  • 5
  • 3
  • 2
3 Solutions
 
praneethaAuthor Commented:
looks like this is something to do with

ASPNET.StarterKit.Portal...
does anyone know what is the purpose of ASPNET.StarterKit.Portal....

is there any advantages of using it...

Thank You.
0
 
nishikanthCommented:
This method returns the correct relative path when installing the portal on a root web site instead of virtual directory
        '


that is a custom fucntion defined in the kit
check this

http://www.devx.com/vb2themax/Tip/19590
0
 
praneethaAuthor Commented:
hi nishi,

i am looking at someone else's code here...and he has used Global.GetApplicationPath...but i have never worked with this kit so i am not aware what it is....

and when i run the asp.net project from my local machine it gives an error saying GetApplicationPath is not a member of Default .... but they allready have it running on the webserver and it seems to work fine there...so is there some setting that it doesn't work locally....do u know....

thank you for your help..i will increase the points if you can help me with this...

and so i erased GetApplicationPath and instead of that Request.ApplicationPath....

is will that make sense...or is it wrong to use Request.ApplicationPath inplace of Global.GetApplicationPath....now i get some other errors...

can you give me some tutorial of how to use this starter kit...

Thank You,
Praneetha Marthala
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ihenryCommented:

Global.GetApplicationPath is not in any part of .NET Framework and I don't know what the function does. For ApplicationPath, if your web app installed in a virtual directory named "app1" it will return "/app1". And if you installed in a root web site, ApplicationPath will just return a "/" which make a relative path become invalid. I found a function some of the starter kits that does something similar with the following (in C#),

public static String AppPath
{
      get {
            if ( HttpContext.Current.Request.ApplicationPath == "/" )
                  return "";
            return HttpContext.Current.Request.ApplicationPath;
      }
}

The property above will always return a correct relative path regardless where you installed your app in IIS. But it still gives problem when your web app request is fed from network balancing that use different protocol like https.
0
 
ihenryCommented:

Btw, I don't know which starter kit are you talking about. You might want to look at this site as a start.
http://www.asp.net/Default.aspx?tabindex=8&tabid=47
0
 
praneethaAuthor Commented:
he used  portal startup kit....

is it good to use this kits...he seemed to modify the code and added whole bunch..how come ...Global.GetApplicationPath is wrking from webserver but throws an error in my llocal computer..do you know...

Thank You.

0
 
nishikanthCommented:
that part ofcode might be a part of his application and not the part of the kit...


As said earlier, it is a custom built procedure...
0
 
ihenryCommented:
this is from starter kits...

Portal Starter Kit - Global.asax.cs
public static string GetApplicationPath(HttpRequest request)
{
      string path = string.Empty;
      try {
            if(request.ApplicationPath != "/")
                  path = request.ApplicationPath;
      }
      catch (Exception e) {
            throw e;
      }

      return path;
}

Community Starter Kit - CommunityGlobals.cs
public static string AppPath {
    get {
      if (HttpContext.Current.Request.ApplicationPath == "/")
          return String.Empty;
      return HttpContext.Current.Request.ApplicationPath;
    }
}

So what exactly is your problem? any exception stack trace error message?
0
 
praneethaAuthor Commented:
he used portal kit...and i found a file called

global.vb...as pasted below..

as i said earlier..it says Global.GetApplicationPath is not a member of default in desktopdefault.aspx page....

and it also throws error near Public Class Global and says i have to say Public Class [Global]...even after changing it that way i still get errors about global.GetApplicationPath...

i really don't know what's happening here..i am just taking look at someone else's code,,,so please help me with this..i increased the points to 500 for this question

Imports System
Imports System.Web


Namespace ASPNET.StarterKit.Portal

    '*********************************************************************
    '
    ' Global Class
    '
    ' This is the class where common methods used accross the application
    ' are implemented
    '
    '*********************************************************************
    Public Class Global


        '*********************************************************************
        '
        ' GetApplicationPath Method
        '
        ' This method returns the correct relative path when installing
        ' the portal on a root web site instead of virtual directory
        '
        '*********************************************************************
        Public Shared Function GetApplicationPath(ByVal request As HttpRequest) As String
            Dim path As String = String.Empty
            Try
                If request.ApplicationPath <> "/" Then
                    path = request.ApplicationPath
                End If
            Catch e As Exception
                Throw e
            End Try

            Return path
        End Function 'GetApplicationPath
    End Class 'Global
End Namespace 'ASPNET.StarterKit.Portal
0
 
praneethaAuthor Commented:
i changed everything from Global.GetApplicationPath to [Global].GetApplicationPath now no compilation error but some SQL error.

Unknown ProviderError Locating Server/Instance Specified
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.Data.SqlClient.SqlException: Unknown ProviderError Locating Server/Instance Specified

Source Error:


Line 18:         ' Obtain the selected item from the HtmlText table
Line 19:         Dim [text] As New ASPNET.StarterKit.Portal.HtmlTextDB()
Line 20:         Dim dr As SqlDataReader = [text].GetHtmlText(ModuleId)
Line 21:    
Line 22:         If dr.Read() Then
 
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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