neda Derakhshesh
neda Derakhshesh

Reputation: 1163

URL changed after running website

I Implement a web site with ASP.net MVC . it works fine in offline. but after uploading project on my Godaddy host, the URL changed.

My host in Godaddy is somehow that it supprts diffrent domains on one host. there is a website in my root and some folders for other websites. a structre is like below

enter image description here

I drag whole project to the folder test. suppose my domain is www.example.com and I Create a folder named test, and then attached the www.example.com to the \test folder. the problem is while I type www.exmple.com in the browser, then press enter, the URL change to 'www.example.com/test/en'( the 'en' is the name of my view) but the problem is that I do not want to have name of my folder(test) in the URL.

I am not sure if the problem is in my side or Godaddy , but here is my route config which it works exactly what I need in offline .

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

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

and here is my controller:

   public class HomeController : Controller
{
    public async Task<ActionResult> Index()
    {


        try
        {
            string userIpAddress = this.Request.UserHostAddress;
            //string userIpAddress = "2.63.255.255";

            var client = new HttpClient
            {
                BaseAddress = new Uri("http://freegeoip.net/xml/")
            };

            var response = await client.GetAsync(userIpAddress);

            var content = await response.Content.ReadAsStringAsync();

            var result = (Response)new XmlSerializer(typeof(Response)).Deserialize(new StringReader(content));
            var country_name = result.CountryName;
            var country_code = result.CountryCode;
            TempData["Country_code"] = country_code;
            TempData["Country_name"] = country_name;

            if (country_code == "FR")
            {


                return RedirectToAction("en", "Home");
            }
            else if (country_code == "JP")
            {


                return RedirectToAction("en", "Home");
            }
            else if (country_code == "DE")
            {


                return RedirectToAction("en", "Home");
            }





            else
            {


                return RedirectToAction("en", "Home");

            }


        }
        catch
        {



            return RedirectToAction("en", "Home");

        }

    }


    public ActionResult en()
    {
        return View();
    }
  }

I want URL just change to www.example.com/en insted of www.example.com/test/en

Appreciate any help.

Upvotes: 1

Views: 143

Answers (0)

Related Questions