Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
0 down vote
favorite


Hi i have published my MVC application on a local server. URL is http://5.189.146.208/DM but few things like Ajax, Jquery and Font awesome not working and giving error 404 in developer console. error screen actually the path in BundleConfig is

C#
bundles.Add(new StyleBundle("~/font-awesome/css").Include(
                      "~/fonts/font-awesome/css/font-awesome.min.css", new CssRewriteUrlTransform()));

which is seen in error also but the application URL have /DM which is the alias or main folder name of application (URL given above), and is not getting caputred in URL and gives error 404 due to mismatch.

And in ajax call i have used dynamic method i.e.

C#
var url = '@Url.Action("GetMonthWiseData","Home")';
                    drawChart(url);
function drawChart(url) {

                $.ajax({
                    type: 'GET',
                    url: url,
                    data: {},
                    dataType: 'json',
                    success: function (data) {
                        var dataset1 = new Array();
                        var dataset2 = new Array();

'@Url.Action("GetMonthWiseData","Home")' but it is also not working. Pls help.

What I have tried:

tried changing the path to relative in Ajax like @url.Action
Posted
Updated 11-Jan-17 14:32pm

Ideally the @Url.Action() gives you the absolute url to the controller. So please check if the Virtual directory (DM) is created properly or not. If it is created properly then you will get url like "http://5.189.146.208/DM/Home/GetCountryWiseData".

Else for a temporary solution, you can use a hardcoded value DM in the Route config.
C#
context.MapRoute(
            name: "app",
            url: "DM/{controller}/{action}/{id}",
            defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
bundles.Add(new StyleBundle("~/font-awesome/css").Include(
                      "~/fonts/font-awesome/css/font-awesome.min.css", new CssRewriteUrlTransform())); //Make sure if <Root>/fonts/font-awesome/css/font-awesome.min.css exists 
Other than this, I dont see any issues with bundles. If they work in IISExpress then will work fine in IIS as well when deployed.
 
Share this answer
 
v2
Comments
Member 12583662 9-Jan-17 5:35am    
Hi SrikantSahu, thanks alot for the reply. I dont want to hardcode the changes as i have to change this again during the development and testing on my local machine.
And directory DM is created and if i mentioned the DM path in URL than it is working fine but the same is not there when runing locally. and also how i make the FontAwesome path dynamic rather than hard coded.
Thanks
F-ES Sitecore 9-Jan-17 11:01am    
Have you created it as a Virtual Directory though? You can't just create a folder called DM, put your files in it and expect .net to know it's not really a folder but the site root.
Member 12583662 10-Jan-17 0:28am    
Hi, Yes it is a virtual directory named DM.
Member 12583662 10-Jan-17 11:51am    
the exact path on server is d:/Guri/DM/
DM is the folder in which all the files and folders of published app is. I have given DM as Virtual Directory name also.
Member 12583662 9-Jan-17 5:39am    
what can i use in replacement of @url.action() to make my path url dynamic. The path at server is "http://5.189.146.208/DM/Home/GetCountryWiseData", but locally it is "http://localhost:(portno)/Home/GetCountryWiseData"
Hi, Now everything working fine. I really dont know what was the issue. I have used CDN now finally for this. But fontawesome dint worked without CDN.
Also i have written CDN in last line in head tag, earlier it was somewhere in center in head tag.

But still dont know what was wrong earlier and why it is working now. I have spent and wasted 5-7 days in this only.

Thanks Everyone, specially SrikantSahu
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900