如何忽略到我的javascript页面的路由 [英] How to I ignore route to my javascript pages

查看:75
本文介绍了如何忽略到我的javascript页面的路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到当我查看我的html pagesource时,我会看到我的javascript引用,当我点击它们时,我可以看到我所有的javascript代码。请问如何限制用户在点击页面源中的链接时查看我的javascript代码。我正在用mvc5编码。



我尝试过:



i noticed that when i view my html pagesource i see my javascript references and when i click on them, i could see all my javascript code. please how to i restrict users from viewing my javascript code when they click on the link in the page source. i'm coding with mvc5.

What I have tried:

public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            routes.IgnoreRoute("/Scripts/{*path}");//this is the path to all my javascript files
            routes.IgnoreRoute("{resource}.config");
            routes.IgnoreRoute("{resource}.cs");
            routes.IgnoreRoute("{*allfiles}", new { allfiles = @".*\.(css|js|gif|jpg|png|doc|docx)" });

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



i这样做但是它不起作用


i did that but it didn't work

推荐答案

你没有。



为了让浏览器执行你的脚本,它必须能够下载你的脚本。如果您阻止用户下载您的脚本,那么您可以阻止浏览器执行您的脚本,并破坏您的网站。



任何需要保密的操作应该在服务器端代码中完成。您在HTML,CSS或Javascript中执行的任何操作都将对所有人可见。
You don't.

In order for the browser to execute your script, it has to be able to download your script. If you prevent the user from downloading your script, then your prevent the browser from executing your script, and you break your site.

Any operation which needs to be kept secret should be done in server-side code. Anything you do in HTML, CSS or Javascript will be visible to everyone.


这篇关于如何忽略到我的javascript页面的路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆