DigitalPlatform / dp2

Integrated Library System / 图书馆集成系统
http://digitalplatform.github.io/dp2
Apache License 2.0
106 stars 54 forks source link

dp2libraryxe安装OPAC后,OPAC缺少样式 #655

Open renyh opened 4 years ago

renyh commented 4 years ago

2020/3/21 安装dp2libraryxe新版本前,先卸载dp2libraryxe并且删除了数据目录,然后重装dp2libraryxe,再安装OPAC,此时supervisor默认密码为空,OPAC未启动。 然后通过内务修改supervisor密码,退出单机版重启单机版,最后在浏览器打开OPAC地址,发现界面缺少样式,如下图: image

DigitalPlatform commented 4 years ago

问题描述

经检查,这是 web.config 中缺乏相应配置参数造成的。

出现问题的安装包中 opac_app.zip 中少了 web.config 文件。dp2libraryxe 安装的时候,它由创建 Web App 阶段(具体来说是添加默认页面 searchbiblio.aspx 时候)自动创建了一个默认的 web.config 文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument enabled="true">
            <files>
                <add value="searchbiblio.aspx" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

其中缺少了必备的一些参数。

解决办法

1) 升级 dp2libraryxe 到最新版本; 2) 使用 dp2libraryxe 菜单命令“维护/重新安装 dp2OPAC 数据目录和应用程序目录”。

然后用户文件夹里面的 opac_app 子目录中的 web.config 文件内容被修改为如下:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="ChartImageHandler" />
      <add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </handlers>
        <defaultDocument enabled="true">
            <files>
                <add value="searchbiblio.aspx" />
            </files>
        </defaultDocument>
    </system.webServer>
</configuration>

3) 重启 dp2libraryxe

问题得到解决

技术原理

web.config 中缺乏

    <modules runAllManagedModulesForAllRequests="true" />

时,ASP.NET 的路由机制就不会发生作用。global.asax 里面的以下路由映射就没有发生作用:

        void RegisterRoutes(RouteCollection routes)
        {
            routes.MapPageRoute("globalRoute3",
                "stylenew/{style}/{filename}",
                "~/css.aspx",true);
            // 2014/12/2
            routes.MapPageRoute("globalRoute2",
    "stylenew/{filename}",
    "~/css.aspx",true);
            routes.MapPageRoute("libraryRoute4",
                "stylenew/{librarycode}/{style}/{filename}",
                "~/css.aspx",true);
        }

于是 http://localhost:8081/dp2OPAC/stylenew/0/head.css 这样的 URL 就无法访问到 css.aspx(会返回 404 错误)。dp2OPAC 中的样式都是通过 css.aspx 动态发生的。

renyh commented 4 years ago

2020/3/21-2047:全新安装dp2libaryxe新版本,安装OPAC,样式正常。 操作步骤如下: 1)安装dp2libraryxe新版本前,先卸载dp2libraryxe并且删除了数据目录。 2)通过clickonce重装dp2libraryxe,再安装OPAC,此时supervisor默认密码为空,OPAC未启动。 3)通过内务修改supervisor密码,退出dp2libraryxe再重启dp2libraryxe(也可以通过dp2libraryxe菜单"工具/启动IIS Express"启动OPAC,但退出再重启dp2libraryxe操作和思考更简单)。 4)点dp2libraryxe的菜单“打开浏览器访问dp2OPAC",系统自动在浏览器打开单机版的OPAC,拷贝这个地址,开一个无痕浏览器窗口,再输入OPAC地址,界面样式显示正常。

注意测试OPAC等WEB界面系统时,一定要先清除浏览器缓存,或者用无痕窗口测试,避免缓存干扰,无法暴露问题。