Как переписать URL страницы с помощью global.asax fle - PullRequest
0 голосов
/ 12 апреля 2019

Я работаю с веб-проектом. теперь я застрял вокруг переписывания URL. Я погуглил, но я не могу получить решение для этого. у меня есть один файл global.asax, как этот.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.Routing;

namespace Admin_Staff_Care
{
    public partial class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }

        static void RegisterRoutes(RouteCollection routes)
        {
            routes.Add("alaram_list", new Route("alaram list", new CustomRouteHandler("~/alaram_list.aspx")));
            routes.Add("alaram_view", new Route("alaram view", new CustomRouteHandler("~/alaram_view.aspx")));
            routes.Add("assign_pricelist_to_party_type", new Route("assign pricelist to party type", new CustomRouteHandler("~/assign_pricelist_to_party_type.aspx")));
            routes.Add("assign_tour_route_tostaff", new Route("assign tour route tostaff", new CustomRouteHandler("~/assign_tour_route_tostaff.aspx")));
            routes.Add("change_request_list", new Route("change request list", new CustomRouteHandler("~/change_request_list.aspx")));
            routes.Add("collection_list", new Route("collection list", new CustomRouteHandler("~/collection_list.aspx")));
            routes.Add("collection_view", new Route("collection view", new CustomRouteHandler("~/collection_view.aspx")));
            routes.Add("complain_list", new Route("complain list", new CustomRouteHandler("~/complain_list.aspx")));
            routes.Add("complain_view", new Route("complain view", new CustomRouteHandler("~/complain_view.aspx")));
            routes.Add("dashboard", new Route("dashboard", new CustomRouteHandler("~/dashboard.aspx")));
            routes.Add("data_grid", new Route("data grid", new CustomRouteHandler("~/data_grid.aspx")));
            routes.Add("delete_old_data", new Route("delete old data", new CustomRouteHandler("~/delete_old_data.aspx")));
            routes.Add("delivery_generate", new Route("delivery generate", new CustomRouteHandler("~/delivery_generate.aspx")));
            routes.Add("delivery_priority", new Route("delivery priority", new CustomRouteHandler("~/delivery_priority.aspx")));
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}

и вот мой код обработчика остался в каталоге App_code

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using System.Web.Routing;
using System.Web.Compilation;
using System.Web;
using System.Web.UI;

public class CustomRouteHandler : IRouteHandler
{
    private string _virtualPath;

    public CustomRouteHandler(string vPath)
    {
        _virtualPath = vPath;
    }
    public string VirtualPath
    {
        get
        {
            return _virtualPath;
        }
        private set
        {
            _virtualPath = value;
        }
    }

    public IHttpHandler GetHttpHandler(RequestContext requestContext)
    {
        var redirectPage = (dynamic)null;
        redirectPage = BuildManager.CreateInstanceFromVirtualPath(VirtualPath, typeof(Page));
        return redirectPage;
    }
}

Как бы то ни было, это не может повлиять на хостинг на iis 7.0, это выдает ошибку вроде:

enter image description here

------------------------------- Обновлено ------------ ------------------- это мой код веб-конфигурации:

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
  <system.webServer>
<modules runAllManagedModulesForAllRequests="true">
      <add name="UrlRoutingModule"
         type="System.Web.Routing.UrlRoutingModule, 
               System.Web.Routing, 
               Version=3.5.0.0, 
               Culture=neutral, 
               PublicKeyToken=31BF3856AD364E35"/>
    </modules>
    <defaultDocument>
      <files>
        <clear/>
        <add value="Login.aspx"/>
      </files>
    </defaultDocument>
    <validation validateIntegratedModeConfiguration="false"/>
    <handlers>
      <remove name="ChartImageHandler"/>
      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
      <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"/>
   <add name="UrlRoutingHandler" 
         preCondition="integratedMode" 
         verb="*" 
         path="UrlRouting.axd" 
         type="System.Web.HttpForbiddenHandler, 
               System.Web, Version=2.0.0.0, 
               Culture=neutral, 
               PublicKeyToken=b03f5f7f11d50a3a" />
  </handlers>
  </system.webServer>
  <system.web>
    <customErrors mode="Off"/>
  </system.web>
</configuration>

пожалуйста, помогите мне выбраться из этого парня

...