关于友好的URL和ViewSwitcher,似乎没有什么可用的信息。
在创建一个文件Default.Mobile.aspx并为其分配一个母版页Site.Mobile.Master之后,总是会返回一个404 'not‘错误。
有什么想法可能会出错,和/或有什么好的参考资料吗?我唯一能找到的东西是2012年或更久的。
IIS是v7.0 (但VS 2013正在模拟IIS 8.0)。项目是包含MVC的web表单。引导程序正在被使用
谢谢
===========================编辑==========================================
我现在试着“开箱即用”创建三个单独的项目。
ASP.Net Web应用程序表单和添加MVC和/或API或仅仅是普通表单
添加Default.Mobile.aspx文件并将其分配给Site.Mobile.Master -每次运行时都会收到相同的404错误
然后,我创建了一个Web项目--Web溶胶- Visual 2012 ASP.NET Web应用程序。这样,Default.Mobile.aspx表单将运行并切换到主默认文件,但不会再次切换。
在所有口味中,ViewSwitcher.ascx控件仅显示为'view _‘_
=====================编辑2014年10月1日=========================
解决了ViewSwitcher.ascx问题。Page_Load事件在ViewSwithcher.ascx.vb中没有连接到末尾,并且显示正确的文本,但仍然无法显示移动视图-叹息。
发布于 2015-02-16 01:54:02
这是支持在桌面和移动页之间切换的完整Page_Load代码。它包括处理MyBase.Load和.__FriendlyUrls_SwitchViews = True额外参数
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Determine current view
Dim isMobile = WebFormsFriendlyUrlResolver.IsMobileView(New HttpContextWrapper(Context))
CurrentView = If(isMobile, "Mobile", "Desktop")
' Determine alternate view
AlternateView = If(isMobile, "Desktop", "Mobile")
Dim strSwitchViewRouteName As String = "AspNet.FriendlyUrls.SwitchView"
Dim SwitchViewRoute = RouteTable.Routes(strSwitchViewRouteName)
If SwitchViewRoute Is Nothing Then
' Friendly URLs is not enabled or the name of the switch view route is out of sync
Me.Visible = False
Return
End If
' Create switch URL from the route, e.g. ~/__FriendlyUrls_SwitchView/Mobile?ReturnUrl=/Page
Dim url = GetRouteUrl(strSwitchViewRouteName, New With { _
Key .view = AlternateView, .__FriendlyUrls_SwitchViews = True _
})
url += "?ReturnUrl=" & HttpUtility.UrlEncode(Request.RawUrl)
SwitchUrl = url
End Sub发布于 2014-10-02 19:58:16
通过将此添加到web.config,解决了404错误的问题
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="ScriptCompressionModule" type="Westwind.Web.ScriptCompressionModule,Westwind.Web" />
</modules>现在只剩下一件事,就是_ViewSwitcher.vbhtml没有开火--越来越近了:-)
https://stackoverflow.com/questions/26066515
复制相似问题