Fazer uma PerguntaFazer uma Pergunta
 

RespondidoWCF equivalent to MapPath?

  • terça-feira, 9 de janeiro de 2007 16:32KevinBurton Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    Is there a WCF equivalent to MapPath? I have some specific files that will be in the directory where the service is running. My question stems from the fact that MapPath bacially is called from a static HttpContext. I understand that this isn't a problem if the service is hosted in IIS but will there be an HttpContext for all hosting environments? What would be the safest way to get the "root" directory of a WCF service? Thank you.

    Kevin Burton

    HttpContext.Current.Server.MapPath

Respostas

  • segunda-feira, 26 de fevereiro de 2007 16:31Wenlong Dong Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    Hi Kevin, using HostingEnvironment plus VirtualPathExtension is the right thing to map virtual paths to physical paths. This works fine for any IIS/WAS hosted services, even for Cassini. What other hosts are you talking about please?

Todas as Respostas

  • domingo, 25 de fevereiro de 2007 22:02Brian McNamara - MSFT Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

    There is an HttpContext only when webhosted in aspnetCompatibilityMode, see http://msdn2.microsoft.com/en-us/library/aa702682.aspx for details.

    I don't think there is an equivalent for other hosting environments... what is your ultimate goal?

  • segunda-feira, 26 de fevereiro de 2007 0:14KevinBurton Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     
     Brian McNamara - MSFT wrote:

    There is an HttpContext only when webhosted in aspnetCompatibilityMode, see http://msdn2.microsoft.com/en-us/library/aa702682.aspx for details.

    I don't think there is an equivalent for other hosting environments... what is your ultimate goal?

     

    The ultimate goal would be to have a single call that would tell me the virtual directory of the service similar to MapPath. If the WCF service is hosted by IIS then HttpContext is null so in that case I have been directed to the HostingEnvironment class. But this class does not really exist for other hosts. I was looking for a single call that would tell me where the service "root" directory is so I can put various configuration files there and I don't have to hard code the path names to these files.

    In addition I have been directed to VirtualPathExtension but I have not tried this yet.

    http://blogs.msdn.com/wenlong/archive/2006/02/21/read-configuration-data-from-hosted-wcf-services.aspx

    Kevin

  • segunda-feira, 26 de fevereiro de 2007 16:31Wenlong Dong Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     Respondido
    Hi Kevin, using HostingEnvironment plus VirtualPathExtension is the right thing to map virtual paths to physical paths. This works fine for any IIS/WAS hosted services, even for Cassini. What other hosts are you talking about please?
  • segunda-feira, 26 de fevereiro de 2007 16:59KevinBurton Medalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuárioMedalhas de usuário
     

     Wenlong Dong wrote:
    Hi Kevin, using HostingEnvironment plus VirtualPathExtension is the right thing to map virtual paths to physical paths. This works fine for any IIS/WAS hosted services, even for Cassini. What other hosts are you talking about please?

     

    If that is correct then that is my answer. Thank you.