سلام وقت بخیر
من برای کوتاه سازی url ها از کد زیر استفاده میکنم و در زمانی که از این کد استفاده میکنم به درستی جواب میده
route.MapPageRoute("tag", "tag/{id}/{*text}", "~/showdetalis.aspx");
ولی زمانی که میخوام format صفحه رو به تگ مورد نظر بچسبونم خطا میده و فقط همون صفحه رفرش میشه
routes.MapPageRoute( "ManyParam", "{*path}", "~/Default.aspx", false, new RouteValueDictionary(), new RouteValueDictionary { { "path", @".*\.html" } } );
ممنون میشم راهنمایی کنید
منظورتون از فرمت چیست ؟
نمونه url را قرار دهید
مهندس یچیزی شبیه ادرس همین صفحه ، فقط سایت من با asp هست
تنظیمات Web.Config را انجام دادید ؟
نه فقط در global این تابع رو اضافه کردم
protected void Application_Start(object sender, EventArgs e) { ; RoutingSite(RouteTable.Routes); } public static void RoutingSite(RouteCollection route) { route.MapPageRoute("homepage", "home", "~/"); . . . . }
تنظیمات دیگه ای نیاز هست ؟
<system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer>
مهندس بعد از اضافه کردن کدهای بالا به این خطا برخورد کردم :
<validation validateIntegratedModeConfiguration="false" />
متن خطا
ممنون که وقت گذاشتید
کد کامل وب کانفیگ را قرار دهید تا ویرایش کنم
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.webServer> <handlers> <add name="AjaxFileUploadHandler" verb="POST" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /> </handlers> <security> <requestFiltering> <requestLimits maxAllowedContentLength="1073741824" /> </requestFiltering> </security> </system.webServer> <connectionStrings> <add name="ConnectionString" connectionString="Data Source= ;Persist Security Info=True;User ID=ctaapir_shop;Password= " providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <httpHandlers> <add verb="*POST" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /> </httpHandlers> <compilation targetFramework="4.5.2" /> <httpRuntime targetFramework="4.5.2" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> <pages> <controls> <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /> </controls> </pages> <customErrors defaultRedirect="Default.aspx" mode="RemoteOnly" redirectMode="ResponseRedirect"> <error statusCode="500" redirect="404.aspx" /> </customErrors> </system.web> <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> </appSettings> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> </compilers> </system.codedom> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules> <remove name="ApplicationInsightsWebTracking" /> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> </modules> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="AjaxControlToolkit" publicKeyToken="28f01b0e84b6d53e" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-16.1.1.0" newVersion="16.1.1.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <add name="AjaxFileUploadHandler" verb="POST" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /> </handlers> <security> <requestFiltering> <requestLimits maxAllowedContentLength="1073741824" /> </requestFiltering> </security> <modules runAllManagedModulesForAllRequests="true"> <remove name="ApplicationInsightsWebTracking" /> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" /> </modules> </system.webServer> <connectionStrings> <add name="ConnectionString" connectionString="Data Source= ;Persist Security Info=True;User ID=ctaapir_shop;Password= " providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <httpHandlers> <add verb="*POST" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" /> </httpHandlers> <compilation targetFramework="4.5.2" /> <httpRuntime targetFramework="4.5.2" /> <httpModules> <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" /> </httpModules> <pages> <controls> <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" /> </controls> </pages> <customErrors defaultRedirect="Default.aspx" mode="RemoteOnly" redirectMode="ResponseRedirect"> <error statusCode="500" redirect="404.aspx" /> </customErrors> </system.web> <appSettings> <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" /> </appSettings> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" /> </compilers> </system.codedom> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="AjaxControlToolkit" publicKeyToken="28f01b0e84b6d53e" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-16.1.1.0" newVersion="16.1.1.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
سلام دوسته عزیز این url رو اگه اوکی کردید ممنون میشم به منم توضح بدید
استاد حالا با این کد میتونم ادرس صفحه رو بسازم ؟
routes.MapPageRoute( "ManyParam", "{*path}", "~/Default.aspx", false, new RouteValueDictionary(), new RouteValueDictionary { { "path", @".*\.html" } } );
یا اینکه روش خاصی داره ؟ ممنون از صبر و شکیبایتون استاد عزیز
بله میشه
هیچ کاربری تا کنون از این پست تشکر نکرده است
با ما تماس بگیرید تا در این مسیر همراهتان باشیم :)