我尝试在每个网址结尾处获得一个"/":
example.com/art
应该
example.com/art/
我使用nginx作为webserver.
我需要重写规则..
为了更好地理解,请检查:
http://3much.schnickschnack.info/art/projekte
如果你按下大图下的一个小缩略图,它会重新加载并显示这个网址:
http://3much.schnickschnack.info/art/projekte/#0
如果我现在在所有网址上都有一个斜杠(最后),那么无需重新加载网站即可.
现在我在nginx-http.conf中有这个设置:
server {
listen *:80;
server_name 3much.schnickschnack.info;
access_log /data/plone/deamon/var/log/main-plone-access.log;
rewrite ^/(.*)$ /VirtualHostBase/http/3much.schnickschnack.info:80/2much/VirtualHostRoot/$1 last;
location / {
proxy_pass http://cache;
}
}
Run Code Online (Sandbox Code Playgroud)
如何配置nginx以添加斜杠?(我想我应该重写规则?)
我有一个Web API方法,需要两个双参数:
存储库界面:
public interface IInventoryItemRepository
{
. . .
IEnumerable<InventoryItem> GetDepartmentRange(double deptBegin, double deptEnd);
. . .
}
Run Code Online (Sandbox Code Playgroud)
库:
public IEnumerable<InventoryItem> GetDepartmentRange(double deptBegin, double deptEnd)
{
// Break the doubles into their component parts:
int deptStartWhole = (int)Math.Truncate(deptBegin);
int startFraction = (int)((deptBegin - deptStartWhole) * 100);
int deptEndWhole = (int)Math.Truncate(deptEnd);
int endFraction = (int)((deptBegin - deptEndWhole) * 100);
return inventoryItems.Where(d => d.dept >= deptStartWhole).Where(e => e.subdept >= startFraction)
.Where(f => f.dept <= deptEndWhole).Where(g => g.subdept >= endFraction);
}
Run Code Online (Sandbox Code Playgroud)
控制器: …
我基本上有一个开箱即用的MVC 5.2 app,启用了基于属性的路由(routes.MapMvcAttributeRoutes();从提供的RouteConfig.RegisterRoutes(RouteCollection routes)方法调用).
以下是HomeController:
[Route("hello.txt")]
[Route("hellotxt-testing")]
public ActionResult ShowFile()
{
return Content("Hello world");
}
Run Code Online (Sandbox Code Playgroud)
我可以成功访问/hellotxt-testing(证明基于属性的路由正常工作):

但如果我访问,我会得到404页/hello.txt:

与我去的/hello404地方相比,我得到了另一个404页面:

我猜第二个404页面来自ASP.NET,而第一个是来自IIS甚至没有将请求传递给ASP.NET?
我该怎么做才能确保我能确保ASP.NET获取这些包含句点的URL?还有其他"特殊"字符也会导致问题吗?