简体   繁体   English

在IIS中托管WPF应用程序

[英]Hosting WPF application within IIS

I have created a WPF application (contains 8 projects). 我创建了一个WPF应用程序(包含8个项目)。 one project is of type (Class Library) ,this dll contains class which implement System.Web.IHttpHandler as the following. 一个项目是(类库)类型的,此dll包含实现System.Web.IHttpHandler的类,如下所示。

public class ReportFileHttpHandler : IHttpHandler
{
    public bool IsReusable
    {
        get { return false; }
    }

    public void ProcessRequest(HttpContext context)
    {
        // some code
    }
 }

this HttpHandler is designed to interrupt the IIS request and handle the requrest of the xml file. 此HttpHandler旨在中断IIS请求并处理xml文件的要求。

I also created a web.config file which exists inside this dll. 我还创建了一个存在于此dll中的web.config文件。

 <system.webServer>
<handlers>
  <add verb="*" path="*.xml" type="ReportFileHttpHandler"  name="ReportFileHttpHandler"/>
</handlers>

Every thing is good here. 这里的一切都很好。 I want to do the following : I want to test the code inside the "ReportFileHttpHandler" ,so I need to host the my WPF application within (inside) the IIS to make test. 我要执行以下操作:我想测试“ ReportFileHttpHandler”中的代码,因此需要在IIS中(内部)托管WPF应用程序以进行测试。 in this way I can write URL inside the Browser (which end with .xml) to execute the code in the method 这样,我可以在浏览器中写入URL(以.xml结尾)以执行方法中的代码

public void ProcessRequrest(HttpContext context)

How can I Host the WPF application inside the IIS ? 如何在IIS中托管WPF应用程序?

any idea will be helpful, thank you 任何想法都会有所帮助,谢谢

  1. Create a webapplication in IIS say MyWPFApp. 在IIS中创建一个Web应用程序,例如MyWPFApp。
  2. Set physical path of application to directory where ReportFileHttpHandler assembly resides say C:\\xxx\\ReportFileHttpHandler\\bin\\Debug. 将应用程序的物理路径设置为ReportFileHttpHandler程序集所在的目录,例如C:\\ xxx \\ ReportFileHttpHandler \\ bin \\ Debug。
  3. Make sure that ReportFileHttpHandler.dll and web.config are in same directory. 确保ReportFileHttpHandler.dll和web.config在同一目录中。
  4. Browse url http://localhost/mywpfapp/myfile.xml in browser. 在浏览器中浏览URL http://localhost/mywpfapp/myfile.xml
  5. If you attach w3wp.exe process corresponding to app pool of your web application in Visual Studio, you should be able to debug your handler dll. 如果在Visual Studio中附加了与Web应用程序的应用程序池相对应的w3wp.exe进程,则应该能够调试处理程序dll。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM