SignalR 在本地主机上工作,但在 Azure 中部署时不起作用
Asp.net Core 1.0.0 (.Net Framework 4.6.1)
SignalR.Core 2.2.1
public static void UseSignalR2(this IApplicationBuilder app)
{
app.UseAppBuilder(appBuilder => {
appBuilder.MapSignalR(new HubConfiguration());
});
GlobalHost.HubPipeline.AddModule(new ErrorHandlingPipelineModule());
GlobalHost.HubPipeline.AddModule(new LoggingPipelineModule());
}
Run Code Online (Sandbox Code Playgroud)
SignalR.js 2.2.1 使用默认设置
$.connection.hub.url = '/signalr';
200 为网址:
https://( name ).azurewebsites.com/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22productsimporthub%22%7D%5D&_=1472811629592
/signalr/negotiate - 在 localhost 上返回 200,但在 azure 中部署的应用程序返回 404
/signalr - 适用于两者 - 协议错误:未知传输。
/signalr/hubs - 适用于两者 - 正确返回 SignalR js
model-view-controller azure http-status-code-404 signalr asp.net-core
我一直试图通过Apache Tomcat嵌入到应用程序中来使我的 Java 应用程序托管一个网页(一个 HTML 页面,而不是 JSP)。我使用Maven了在构建系统NetBeans IDE 8.0.2.出于某种原因,Tomcat拒绝承认index.html我已经放置在应用程序页面,尽管多次尝试和创建各种文件夹一样的WEB-INF。但它仍然404向我抛出错误。
这是我在我的项目中设置的一些相关代码(一些代码已被省略但与情况无关):
1. MainApplication.java - 启动 Tomcat
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.io.*;
import java.util.Optional;
import org.apache.catalina.startup.Tomcat;
public class MainApplication{
public static final Optional<String> port = Optional.ofNullable(System.getenv("PORT"));
public static void main(String[] args) throws Exception {
String contextPath = "/";
String appBase = ".";
Tomcat tomcat = new Tomcat();
tomcat.setPort(Integer.valueOf(port.orElse("8080")));
tomcat.getHost().setAppBase(appBase);
tomcat.addWebapp(contextPath, appBase);
tomcat.start();
tomcat.getServer().await(); …Run Code Online (Sandbox Code Playgroud) public IEnumerable<xxx.Models.Product> ReviewAll(string para1, string para2, string para3, int para4)
{
return //HTTPStatusCode
}
Run Code Online (Sandbox Code Playgroud)
目前我正在使用这个
int HTTPResponse=400;
return Request.CreateResponse((HttpStatusCode)HTTPResponse, "InvalidID");
Run Code Online (Sandbox Code Playgroud)
但这会返回一个错误说
无法将类型“System.Net.Http.HttpResponseMessage”隐式转换为“System.Collections.Generic.IEnumerable”。存在显式转换(您是否缺少演员表?)
如何解决这个问题??
无法使用 spring-boot 加载非常简单的 JSP 页面,出现 404 Not Found
应用程序类
@SpringBootApplication
public class HmisApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(HmisApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(HmisApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
主控制器.java
@Controller
public class WelcomeController {
@RequestMapping("/")
public String home(Map<String, Object> model) {
model.put("message", "HowToDoInJava Reader !!");
return "index";
}
@RequestMapping("/next")
public String next(Map<String, Object> model) {
model.put("message", "You are in new page !!");
return "next";
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序属性
spring.profiles.active=dev,build-info
server.contextPath=/hmis
server.port=7070
spring.metrics.export.enabled=true …Run Code Online (Sandbox Code Playgroud) 我刚开始使用 angular js,我尝试了路由并且工作得很好。问题是当我刷新页面时它显示 404 错误,因为它正在检查我的实际目录而不是检查路由。
这是完整的代码
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.js"></script>
<body ng-app="myApp">
<base href="/" />
<a href="blue">blue</a>
<a href="green">green</a> //blue.html and green.html are in same directory as index.html
<p>Click on the links to load blue or green.</p>
<div ng-view></div>
<script>
var app = angular.module("myApp", ["ngRoute"]);
app.config(function($routeProvider, $locationProvider) {
$routeProvider
.when("/blue/:name?", {
templateUrl: "blue.html",
controller: "blue_control"
})
.when("/green", {
templateUrl: "green.html",
controller: "green_control"
})
$locationProvider.html5Mode({
enabled: true
});
});
app.controller("blue_control", function($scope) {
$scope.msg = "this is blue";
}); …Run Code Online (Sandbox Code Playgroud) javascript http-status-code-404 angularjs ngroute angularjs-ng-route
在 Angular 中,我了解如何使用通配符路由来显示自定义 404 页面。但是,这仅涵盖不存在组件的情况。
用户到达现有组件但传递了不存在的 ID 的情况如何?
例如/widgets/12345其中12345不存在于数据库中。在这种情况下显示 404 的最佳做法是什么?
我设法通过捕获错误将用户重定向到 404 页面。但这似乎不对:您通常不会被重定向到 404,您希望停留在相同的 URL 上,而是使用 404 页面。
您好,我正在尝试使用 Eclipse 通过一个非常简单的应用程序来学习 Wildfly 和 springboot。项目名称是 springboot-test。包括主方法类在内的所有类都在同一个包中。
Main 方法类称为“App”,其代码如下:
@SpringBootApplication
@RestController
public class App {
@Autowired
private Student student;
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
@RequestMapping("/index")
public String sayHello()
{
return "hello from spring boot" + this.student.showAddress();
}
}
Run Code Online (Sandbox Code Playgroud)
以下是服务器日志:
11:36:57,281 信息 [org.wildfly.extension.undertow](ServerService 线程池 - 68)WFLYUT0021:已注册的 Web 上下文:服务器“default-server”的“/springboot-test-0.0.1-SNAPSHOT”
11:36:57,301 信息 [org.jboss.as.server](ServerService 线程池 - 37)WFLYSRV0010:部署了“springboot-test-0.0.1-SNAPSHOT.war”(运行时名称:“springboot-test-0.0” .1-SNAPSHOT.war")
11:36:57,408 信息 [org.jboss.as.server](控制器引导线程)WFLYSRV0212:恢复服务器
11:36:57,411 INFO [org.jboss.as](控制器启动线程)WFLYSRV0060:Http 管理接口监听http://127.0.0.1:8181/management
11:36:57,412 INFO [org.jboss.as](控制器启动线程)WFLYSRV0051:管理控制台监听http://127.0.0.1:8181
11:36:57,412 INFO [org.jboss.as](控制器启动线程)WFLYSRV0025:WildFly Full 11.0.0.Final(WildFly Core 3.0.8.Final)在 11393 毫秒内启动 - …
在实时服务器上部署项目时出现 404 错误。我收到了一个 Laravel 页面,说Sorry, the page you are looking for could not be found.我知道它正在到达我的项目。
我运行php artisan config:cache并php artisan route:cache注册了我的路由和缓存,但它仍然没有改变。不太确定为什么我会收到此错误。我的 vhost 中的文档根目录也设置为我的公共文件夹。
我采取的部署步骤
777(我知道这是错误的,我只是想让它部署并查看它是否有错误)project/public虚拟主机
<IfModule mod_ssl.c>
<VirtualHost *:443>
DocumentRoot /var/www/html/API/public
#DocumentRoot /var/www/API/public/
ServerName api.app.io
ServerAlias api.app.io
ErrorLog ${APACHE_LOG_DIR}/api-error.log
CustomLog ${APACHE_LOG_DIR}/api-access.log combined
<Directory "/var/www/API/public">
#Options +Includes
#Options +FollowSymLinks -Indexes
Options All
AllowOverride All
Require all granted
</Directory>
SSLCertificateFile /etc/letsencrypt/live/api.app.io/cert.pem
SSLCertificateKeyFile …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 keycloak AdminAPI ( https://www.keycloak.org/docs-api/3.0/rest-api/index.html#_users_resource ) 创建用户并分配客户端角色。我收到正确的令牌,并且创建了用户但分配角色返回 404
我正在使用 Postman 连接 API:
/auth/realms/{realmName}/protocol/openid-connect/token
Content-Type application/x-www-form-urlencoded <-with parameters ofc
/auth/admin/realms/{realmName}/users
Content-Type application/json
Authorization Bearer {TOKEN}
Body:
Run Code Online (Sandbox Code Playgroud)
{
"username": "name",
"enabled": true,
"emailVerified": false,
"firstName": "first",
"lastName": "last",
"credentials": [
{
"type": "password",
"value": "newPas1*",
"temporary": false
}
]
}
Run Code Online (Sandbox Code Playgroud)
以上对我有用,但下一个不行
/auth/admin/realms/{realmName}/users/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/role-mappings/clients/realm-management
Content-Type application/json
Authorization Bearer {TOKEN}
Body:
Run Code Online (Sandbox Code Playgroud)
{
"roles": [
{
"id": "0830ff39-43ea-48bb-af8f-696bc420c1ce",
"name": "create-client",
"description": "${role_create-client}",
"composite": false,
"clientRole": true,
"containerId": "344e7c81-e7a2-4a43-b013-57d7ed198eee"
}
]
}
Run Code Online (Sandbox Code Playgroud)
其中 'xxxxxx-xxxx-xxxx-xxxx-xxxxxxxx' 是创建期间返回的用户 ID,并且存在创建客户端角色
我需要一种通过 …
我正在开发一个 Spring Boot 应用程序。我在点击我配置的 URL 路径时收到404 错误。我哪里错了?
主控制器.java
package com.example.homes;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController("/add")
public class HomeController {
@GetMapping("/hello")
public String add() {
return "Hello";
}
}
Run Code Online (Sandbox Code Playgroud)
主页应用程序.java
package com.example.homes;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class HomeApplication {
public static void main(String[] args) {
SpringApplication.run(HomeApplication.class, args);
System.out.println("Inside main");
}
}
Run Code Online (Sandbox Code Playgroud)