1

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.

neda Derakhshesh
  • 1,103
  • 2
  • 20
  • 43
  • Is there some reason you can't put it at top level? – Daxtron2 May 24 '18 at 12:51
  • 1
    It is highly likely the problem you are having has got to do with how GoDaddy is configured to host your site. – junkangli May 24 '18 at 12:53
  • So you want two websites to be accessible by the top-level url? – Daxtron2 May 24 '18 at 14:01
  • Top-level refers to the highest level of your domain so if you had `www.website.com`, the site you reached by only putting in `www.website.com` is the highest level/root/toplevel. There's several words for it. – Daxtron2 May 24 '18 at 14:04
  • As far as I know, and don't take my word as law, you can't have `www.example.com` point to two different sites, as that wouldn't make sense. I might also be misunderstanding you, so feel free to clarify. – Daxtron2 May 24 '18 at 14:06
  • @TJWolschon yes its misunderstanding. domains are not pointing in one websites. each folder has different website, and each domains attached to different folders – neda Derakhshesh May 24 '18 at 14:11
  • 1
    @junkangli what do you mean? you mean I should ask godaddy? support? – neda Derakhshesh May 24 '18 at 14:12
  • @neda Derakhshesh yes, or their documentation. – junkangli May 26 '18 at 01:54
  • @junkangli they claim that they can not do something that any folder acts like a root. just root can act like root. but they claim that I can have multi domain on one host. so thats why this happen. is there any way that me as a developer can do? – neda Derakhshesh May 31 '18 at 11:15
  • 1
    Is it not possible for you to go with their suggestion - "have multi domain on one host"? Otherwise, as @TJWolschon asked, "Is there some reason you can't put it at top level?" – junkangli May 31 '18 at 12:02
  • "multi domain on one host" means two different domains ("example1.com" and "example2.com") are both under the same server/host. – Daxtron2 May 31 '18 at 12:03
  • @TJWolschon yea I have different domains and websites on one host, html projects works fine , but MVC projects is like mess, in root MVC is fine , but for others, they need their folder to act like root , but they can not give me more than one root, so I do not know how multi domain support is this, I just wonder to know what shall I do as a developer? – neda Derakhshesh May 31 '18 at 12:09
  • @junkangli I have one MVC project in root right now, and it works fine. I can not have two different in root of course, I need to put other projects to their own folders – neda Derakhshesh May 31 '18 at 12:11

0 Answers0