Unable to verify the first certificate with postman on new .Net 5 core project - api

i need an help.
So i've created a project .NET core 5 with HTTPS. The project is new new.
So added the TestController where on get request i will have:
// GET: api/<TestController>
[HttpGet]
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
So, if i call the api https://localhost:44310/api/test on the browser:
["value1","value2"]
//that works correctly
But if i call the url on postman i receive:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<TITLE>Bad Request</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii">
</HEAD>
<BODY>
<h2>Bad Request - Invalid Hostname</h2>
<hr>
<p>HTTP Error 400. The request hostname is invalid.</p>
</BODY>
</HTML>
My postman option:
and
and
and
where i'm wrong? I need to settings visual studio with other options? Maybe i need to use localhost certificate? Why i get this error only in postman and not by browser??

Related

Glassfish does not detect the JAX-WS endpoint

Hello am facing a problem in the glassfish server
I have deployed my application with intellij and it has shown me the first page of the Hello World successfully and when I add to the url the name of the service a 404page has been shown
This is the code of the webservice
package test;
import javax.jws.WebMethod;
import javax.jws.WebService;
#WebService(serviceName = "HelloService")
public class Hello {
public Hello() {
}
#WebMethod()
public int calcul (int a , int b){
return a+b;
}
}
the web.xml
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
the index.jsp
<html>
<body>
<h1>Test the application the problem is that the glassfish can't access to the webservers</h1>
<h2>Hello World!</h2>
</body>
</html>
This is when I run the application for the first time
This is when I add the webservice name to the url
This is the Glassfish5 GUI showing it doesn't detect the components of the new webservices
After i tried again and again
I found in other WAR files that the web.xml don't exist
so i deleted the web.xml file and

Safari losing hash params on http redirection

I am facing an issue wherein the url fragments are not getting
preserved on redirect in Safari as they should be according to the
http specifications.
Setting -
`/url1` redirects to `/url2#hash`
`/url2` redirects to `/url3`
Expected behaviour -
Hitting `/url1` should redirect to `/url3#hash`
Observed behaviour -
Chrome/FF - Hitting `/url1` redirects to `/url3#hash`
Safari(11+) - Hitting `/url1` redirects to `/url3`
I did read the issue reported for earlier versions of Safari. I also tried the solutions posted in other SO threads in vain.
Any help is appreciated.
We ran into the same issue today and made some additional observations. We were also able to reproduce the problem with an example Spring Boot app:
#Controller
class RedirectController {
#GetMapping("/url1")
String url1() {
return "redirect:/url2#hash";
}
#GetMapping("/url2")
String url2() {
return "redirect:/url3";
}
#GetMapping("/url3")
#ResponseBody
String url3() {
return "Hello World";
}
}
When running with Safari 14.1.2 on OSX 10.15.7 (Catalina) hitting /url1/ leads to /url3 without carrying over the fragment (#hash) from /url2.
But doing so with Safari 14.1.2 (same version) on OSX 11.5.2 (Big Sur) works. Hitting /url1 leads to /url3#hash.
In any case hitting /url1#this-is-fragment leads to /url3#this-is-fragment.
Our hypothesis is, that Safari (on Catalina) carries over fragments only if they are created in the browser and not on the server. Safari on Big Sur seems to behave like other browsers (e.g. Firefox and Chrome).
Based on that hypothesis one "solution" is a client side redirect, for example via meta refresh:
#Controller
class RedirectController {
#GetMapping("/url1")
#ResponseBody
String url1ClientSideRedirect() {
return """
<html>
<head>
<meta http-equiv="refresh" content="0;URL='/url2#hash'">
</head>
<body></body>
</html>
""";
}
#GetMapping("/url2")
String url2() {
return "redirect:/url3";
}
#GetMapping("/url3")
#ResponseBody
String url3() {
return "Hello World";
}
}
I suppose any client side JavaScript working with window.location would work as well.

SolrJ CloudSolrClient connection error

I am struggling with indexing using Solrj.
I want to use SolrCloud and I set my connection like this :
SolrClient client = new CloudSolrClient.Builder().withSolrUrl("http://localhost:8983/solr/collectioname").build();
And I have this error. I checked evruwhere before posting here but I can't resolve it
Exception in thread "main" java.lang.RuntimeException: Couldn't initialize a HttpClusterStateProvider (is/are the Solr server(s), [http://localhost:8983/solr/collectioname], down?)
at org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.build(CloudSolrClient.java:1496)
at indexsolr.<init>(indexsolr.java:29)
at LoadData.toIndex(LoadData.java:100)
at LoadData.loadDocuments(LoadData.java:72)
at IndexLaunch.main(IndexLaunch.java:12)
Caused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/collectioname: Expected mime type application/octet-stream but got text/html. <html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /solr/collectioname/admin/collections. Reason:
<pre> Not Found</pre></p>
</body>
</html>
at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:607)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:255)
at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:244)
at org.apache.solr.client.solrj.SolrClient.request(SolrClient.java:1219)
at org.apache.solr.client.solrj.impl.HttpClusterStateProvider.fetchLiveNodes(HttpClusterStateProvider.java:189)
at org.apache.solr.client.solrj.impl.HttpClusterStateProvider.<init>(HttpClusterStateProvider.java:64)
at org.apache.solr.client.solrj.impl.CloudSolrClient$Builder.build(CloudSolrClient.java:1494)
... 4 more
As mentioned in the previous answer, SolrJ uses the URL without the collection name in it (which I should have pointed out more directly):
final String solrUrl = "http://localhost:8983/solr";
return new HttpSolrClient.Builder(solrUrl)
.withConnectionTimeout(10000)
.withSocketTimeout(60000)
.build();
For SolrCloud you need to use CloudSolrClient. Depending on Solr version you are using you can create object of CloudSolrClient or you can use CloudSolrClient.Builder
This is how I did it.
Solr cloud just needs to take a list of urls as a parameter and not just a String url.
private static final String BASE_SOLR_URL = "http://localhost:8983/solr";
// or initialize a list of solr instances urls
#Bean(name = "solrCloudClient")
public static CloudSolrClient getCloudConnection() {
System.out.println("----Initializing cloud Solr Connection---");
List<String> solrCloudUrls = Arrays.asList(BASE_SOLR_URL); // or list of urls
CloudSolrClient client = new CloudSolrClient.Builder(solrCloudUrls).build();
client.setParser(new XMLResponseParser());
return client;
}

WebAPI displays 404 error when deploying on Server using IIS 7 but works fine as selfhost

Any help would be greatly appreciated. I have been researching this problem for a couple days now. here is what's happening.
I created my first WebApi service in vs 2012 using the templete under mvc4. I have kept most of the default settings. I did change the router in WebApiConfig.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
namespace GetBalanceSV
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "SubscriberActivity/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
I can run this fine in debug mode on my machine. I published on my machine through VS2012 and ran it as a self host using IIS and can call the get method and get a response back with no problems. using
"http://localhost/SubscriberActivity/Values/Testingingmystring"
I can also deploy this on our web development server with IIS as a new web site in a self host and will run fine on the server that way. BUT when i put under a existing web site using the same Application Pool it fails. 404 error.
I ran this through fiddler2 and this was the response i got.
*HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Mon, 07 Oct 2013 17:04:59 GMT
Content-Length: 1937
<!DOCTYPE html>
<html>
<head>
<title>The resource cannot be found.</title>
<meta name="viewport" content="width=device-width" />
<style>
body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}
p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
pre {font-family:"Consolas","Lucida Console",Monospace;font-size:11pt;margin:0;padding:0.5em;line-height:14pt}
.marker {font-weight: bold; color: black;text-decoration: none;}
.version {color: gray;}
.error {margin-bottom: 10px;}
.expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
#media screen and (max-width: 639px) {
pre { width: 440px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; }
}
#media screen and (max-width: 479px) {
pre { width: 280px; }
}
</style>
</head>
<body bgcolor="white">
<span><H1>Server Error in '/SubscriberActivity' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>The resource cannot be found.</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
<br><br>
<b> Requested URL: </b>/SubscriberActivity/values/testeing<br><br>
</body>
</html>*
Does anyone have any idea why this might be happening?
Check whether Existing App Pool is in Classic or Integrated Mode. If it is Classic Mode then change it to Integrated Mode
Am not exactly sure what you mean by "BUT when i put under a existing web site using the same Application Pool it fails." ... but on any way, i believe your issue is in:
maybe the iis needs an update to support extensionless urls (unless it already worked fine being hosted on same iis that would mean it already support it). check this
Make sure that your http handlers are correct (look at section in web.config in visual studio, and make sure the deployed version has the same http handlers). As am afraid you are deploying the wrong way.
you might also check this link

Accessing XML via Web Handler results in 302 redirect

I'm trying to access an XML file via web handler. I am running into an infinite redirect (302) issue though. This is because cookies are not enabled. I'm not entirely certain what is causing it, but need some help figuring out what to do.
var url = context.Request.QueryString["xmlurl"];
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(url);
hwr.Method = "GET";
hwr.MaximumAutomaticRedirections = 5;
//infinite redirect happens here
HttpWebResponse response = (HttpWebResponse)hwr.GetResponse();
I suspect that the following cookies (found via Fiddler) are required:
ASP.NET_SessionId= ...
.ASPXAUTH= ...
These are created when the page is accessed via browser, but not with my web handler. Does anyone know how I can work around this?
The exact response I get back via web handler is:
<html>
<head>
<title>Object moved</title>
</head>
<body>
<h2>Object moved to here.</h2>
</body>
</html>
The answer ended up being relatively simple. By adding
hwr.CookieContainer = new CookieContainer();
It allowed the server to attach cookies to the response, the redirect was then allowed and the final xml document was delivered.