小编Rob*_*ert的帖子

IIS中的自定义虚拟路径提供程序

在IIS 7.5中实现自定义虚拟路径提供程序的正确配置是什么?使用ASP.NET Development Server从Visual Studio运行时,以下代码按预期工作,但从IIS运行时不加载映像.

.NET 4.0项目文件

CustomVirtualPathProvider.zip - SkyDrive文件

Web.config文件

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.webServer>
     <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

Default.aspx的

<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Virtual Path Provider</title>
    </head>
    <body>
        <img src="Box.png" />
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

Global.asax中

public class Global : System.Web.HttpApplication
{
    void Application_Start(object sender, EventArgs e)
    {
        System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(new WebApplication1.CustomVirtualPathProvider());
    }
}
Run Code Online (Sandbox Code Playgroud)

CustomVirtualFile.cs

public class CustomVirtualFile : System.Web.Hosting.VirtualFile
{
    private string …
Run Code Online (Sandbox Code Playgroud)

asp.net iis-7.5

4
推荐指数
2
解决办法
7912
查看次数

标签 统计

asp.net ×1

iis-7.5 ×1