2

I have done these much for routing

routes.MapRoute(
    name: "Hidden1",
    url: "EditCategoryDetails/{categoryId}",
    defaults: new { controller = "TestController", action = "EditCategory", categoryId = UrlParameter.Optional 
});


routes.MapRoute(
    name: "Hidden2",
    url: "CategoryDetails",
    defaults: new { controller = "TestController", action = "CategoryView" 
});

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "LoginController", action = "Login", id = UrlParameter.Optional
});

After doin this the controller and action names were removed from the Url and were replaced by EditCategoryDetails and CategoryDetails respectively.

The problem is that after routing js and css won't work while the url is localhost/mywebsite/CategoryDetails

and is working when I place a slash(//) manually at the end of address bar

localhost/mywebsite/CategoryDetails/

After searching for the js and css problem I have done this too

routes.IgnoreRoute("{file}.css");
routes.IgnoreRoute("{file}.js");
routes.IgnoreRoute("{file}.jpg");
routes.IgnoreRoute("{file}.gif");

but no hope. Js and css get effected only when I manually add a slash(/) at the end on the address bar of browser.

Am including js and css in the _Layout.cshtml page as

  <link href="~/Content/Site.css" rel="stylesheet" />
  <script src="~/Scripts/jquery-1.7.1.js"></script>

etc.

2
  • can you post how you try to include js and css Commented Jan 13, 2014 at 6:50
  • Pls check. I have added dat too @VolodymyrBilyachat Commented Jan 13, 2014 at 6:59

1 Answer 1

4

Got it right. Some of the scripts of my website was reffered as

 <script src="../Scripts/jquery-1.7.1.js"></script>
 <script src="../Scripts/jquery.easing.1.3.js"></script>

instead of

<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/jquery.easing.1.3.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.