.NET MVC Route无法正常工作

时间:2017-01-29 20:41:27

标签: c# asp.net asp.net-mvc routing routes

我在.NET应用中定义了我的路由,如下所示:

soup = BeautifulSoup(html.read().encode('utf-8'),"html.parser")

这样我可以拥有如下路线:

public static void RegisterRoutes(RouteCollection routes) 
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

    routes.MapRoute(
        name: "Register",
        url: "Register",
        defaults: new { controller = "Home", action = "Register" }
    );

    routes.MapRoute(
        name: "Login",
        url: "Login",
        defaults: new { controller = "Home", action = "Login" }
    );
    routes.MapRoute(
        name: "ResetPwd",
        url: "{action}/{id}",
        defaults: new { controller = "Home", action = "ResetPwd", id = UrlParameter.Optional }
    );

    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
    );
}

现在当我尝试将用户从mysite.com/Login成功登录时尝试将用户重定向到仪表板时,其他控制器出现问题:

mysite.com/Login
mysite.com/Register
mysite.com/ResetPwd

但是我收到了错误:

  

无法找到资源。

我认为我希望我现在为仪表板/索引定义一条路线......但是从那以后我不必手动添加每条路线???

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

将您的重置密码路由更改为

from sklearn.datasets import make_moons
from sklearn.neural_network import MLPClassifier
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt

def get_mlp(resize_batch, n):
    mlp = MLPClassifier(verbose=True, random_state=random_state)
    if resize_batch:
        mlp.batch_size = min(n // 2, 100)
    return mlp

n_samples = [10**2, 10**3, 5*10**3, 10**4, 10**5, 10**6, 10**7]
batch_resize = [False, True]
random_state = 1

results = list()

for n in n_samples:
    x = make_moons(n_samples=n, noise=0.3, random_state=random_state)
    X = StandardScaler().fit_transform(x[0])
    results.append([n])
    for resize in batch_resize:
        mlp = get_mlp(resize, n)
        mlp.partial_fit(X, x[1], [0, 1])
        results[-1].append([mlp.score(X, x[1]), 0, resize])

        mlp = get_mlp(resize, n)
        for i in range(2):

            train_start = i * n // 2
            train_stop = (i + 1) * n // 2
            mlp.partial_fit(X[train_start:train_stop], x[1][train_start:train_stop], [0, 1])
        results[-1].append([mlp.score(X, x[1]), 1, resize])

x = [i[0] for i in results]
colors = ['red', 'green', 'blue', 'black']
labels = ['one call, batch=auto', 'two calls, batch=auto', 'one call, batch=100', 'two calls, batch=100']

fig, ax = plt.subplots()
handles = list()
for n in range(4):
    plt.subplot(210 + i)
    handles.append(plt.plot(x, [i[n + 1][0] for i in results], c=colors[n], label=labels[n])[0])
plt.xscale('log')
plt.legend(handles=handles, loc=2)
plt.show()

目前,您提供的网址 routes.MapRoute( name: "ResetPwd", url: "ResetPwd/{id}", defaults: new { controller = "Home", action = "ResetPwd", id = UrlParameter.Optional } ); 会被此路由查找,/Dashboard/Index是默认Dashboard控制器上的操作,我认为该操作系统不存在。