base-url

How to get base url without accessing a request

安稳与你 提交于 2019-11-29 11:00:53
问题 How to get the base URL in AspNet core application without having a request? I know from the Request you can get the scheme and host (ie $"{Request.Scheme}//{Request.Host}" would give something like https://localhost:5000), but is it possible to get this information from anywhere else? In other words, if I have a service class that needs to build absolute URLs, how can I get the current URL when there is not an http request available? UPDATE: Maybe that scenario does not even make sense since

CodeIgniter - Simple base_url question

限于喜欢 提交于 2019-11-28 13:13:00
I'm a bit confused here. I have a simple controller which loads a view. The view contains a form and links some CSS files. I don't really want to do ../../css/global.css in my link tag. I want to use the base_url() method and then go /css/. I know a friend uses the following: <link href="{base_url}css/style.css" rel="stylesheet" type="text/css" /> However, I can't get that to work. He uses CodeIgniter 1.7 though, I'm using the latest (2.something) version. I'm new to CodeIgniter and I wanted to mess around with it, but I can't even link a simple CSS file :( My view is in /logic/views/index.php

How to set AngularjJS base URL dynamically based on fetched environment variable?

谁都会走 提交于 2019-11-28 10:03:20
I have a development and production environment in which my URL's differ: production: www.exmaple.com/page development: dev.environment/project/page I know that I can set the base URL in AngularJS with the <base href='/project/' /> but that doesn't help me out here. Before I load my AngularJS application I fetch a config file (in app.js, with the .run statement, which reads a variable that has the environment: ]).run([ '$rootScope', '$http', function ( $rootScope, $http ) { var configDeferred = $q.defer(); // fetch config and set the API $http.get('config.json').then(function(response) {

How to get base URL in Web API controller?

为君一笑 提交于 2019-11-28 06:08:04
I know that I can use Url.Link() to get URL of a specific route, but how can I get Web API base URL in Web API controller? Kiran Challa You could use VirtualPathRoot property from HttpRequestContext ( request.GetRequestContext().VirtualPathRoot ) In the action method of the request to the url " http://localhost:85458/api/ctrl/ " var baseUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) ; this will get you http://localhost:85458 Url.Content("~/") worked for me! This is what I use: Uri baseUri = new Uri(Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.PathAndQuery, String.Empty

Laravel: Get base url

假如想象 提交于 2019-11-28 03:13:21
Simple question, but the answer seems quite hard to come by. In Codeigniter, I could load the url helper and then simply do echo base_url(); to get my site's URL. Is there an equivalent in Laravel? You can use the URL facade which lets you do calls to the URL generator So you can do: URL::to('/'); You can also use the application container: $app->make('url')->to('/'); $app['url']->to('/'); App::make('url')->to('/'); Or inject the UrlGenerator: <?php namespace Vendor\Your\Class\Namespace; use Illuminate\Routing\UrlGenerator; class Classname { protected $url; public function __construct

Get Root/Base Url In Spring MVC

早过忘川 提交于 2019-11-27 13:56:56
What is the best way to get the root/base url of a web application in Spring MVC? Base Url = http://www.example.com or http://www.example.com/VirtualDirectory If base url is " http://www.example.com ", then use the following to get the " www.example.com " part, without the "http://": From a Controller: @RequestMapping(value = "/someURL", method = RequestMethod.GET) public ModelAndView doSomething(HttpServletRequest request) throws IOException{ //Try this: request.getLocalName(); // or this request.getLocalAddr(); } From JSP: Declare this on top of your document: <c:set var="baseURL" value="$

How to get base URL in Web API controller?

点点圈 提交于 2019-11-27 11:51:39
问题 I know that I can use Url.Link() to get URL of a specific route, but how can I get Web API base URL in Web API controller? 回答1: You could use VirtualPathRoot property from HttpRequestContext ( request.GetRequestContext().VirtualPathRoot ) 回答2: In the action method of the request to the url "http://localhost:85458/api/ctrl/" var baseUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority) ; this will get you http://localhost:85458 回答3: Url.Content("~/") worked for me! 回答4: This is what I use

How to get domain URL and application name?

為{幸葍}努か 提交于 2019-11-27 10:09:23
Here's the scenario. My Java web application has following path https://www.mywebsite.com:9443/MyWebApp Let's say there is a JSP file https://www.mywebsite.com:9443/MyWebApp/protected/index.jsp and I need to retrieve https://www.mywebsite.com:9443/MyWebApp within this JSP file. Of course, there is rather a lazy and silly way of just getting the URL and then re-tracing the path back. But is there a programatic way of doing this? Specifically, I think I can get the domain + port, but how do I actually retrieve the application name "MyWebApp"? The web application name (actually the context path)

CodeIgniter - Simple base_url question

自作多情 提交于 2019-11-27 07:40:07
问题 I'm a bit confused here. I have a simple controller which loads a view. The view contains a form and links some CSS files. I don't really want to do ../../css/global.css in my link tag. I want to use the base_url() method and then go /css/. I know a friend uses the following: <link href="{base_url}css/style.css" rel="stylesheet" type="text/css" /> However, I can't get that to work. He uses CodeIgniter 1.7 though, I'm using the latest (2.something) version. I'm new to CodeIgniter and I wanted

How to set AngularjJS base URL dynamically based on fetched environment variable?

ε祈祈猫儿з 提交于 2019-11-27 03:22:52
问题 I have a development and production environment in which my URL's differ: production: www.exmaple.com/page development: dev.environment/project/page I know that I can set the base URL in AngularJS with the <base href='/project/' /> but that doesn't help me out here. Before I load my AngularJS application I fetch a config file (in app.js, with the .run statement, which reads a variable that has the environment: ]).run([ '$rootScope', '$http', function ( $rootScope, $http ) { var configDeferred