我有一个本地运行的站点和另外两台服务器(serverA
,serverB
)。我在本地运行IIS 10
,在另外两台服务器上运行IIS 8.5
。
对Web Api 2路由(通过属性路由定义)的请求在我的本地站点和serverA
上正确处理,但不在serverB
上。
在向Web Api 2路由发出请求时,我总是从服务器获得404响应,但其他页面正常运行。
我发现如果我向我的站点根目录添加与请求URL匹配的文件夹,并在最终文件夹中添加index.html
,则正确处理Web Api 2路由请求并返回有效响应。
实施例:
通常,GET domain.com/api/values
的请求会在serverB
上返回404,在{ value1: "1", value2: "2" }
上返回serverA
。
如果serverB
我的网站位于c:\site
并且我确保c:\site\api\values\index.html
存在(即使index.html
为空),则会GET domain.com/api/values
,{ value1: "1", value2: "2" }
将返回web.config
{1}}。
我认为在一台服务器上使用无扩展路由或请求处理程序错误配置了某些内容但是在比较三台服务器上的serverB
网站时,我还没有弄清楚问题/区别是什么。< / p>
我以前从未见过这种行为。
以下是我的web.config -> system.webServer
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
<remove name="XHtmlModule" />
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="UrlRoutingHandler" />
<remove name="WebDAV" />
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,OPTIONS,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,OPTIONS,DELETE" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="Script" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,OPTIONS,DELETE" type="System.Web.Handlers.TransferRequestHandler" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv4.0" responseBufferLimit="0" />
</handlers>
</system.webServer>
部分
import numpy as np
import matplotlib.pyplot as plt
import cifar_tools
import tensorflow as tf
data, labels = cifar_tools.read_data('C:\\Users\\abc\\Desktop\\Testing')
x = tf.placeholder(tf.float32, [None, 150 * 150])
y = tf.placeholder(tf.float32, [None, 2])
w1 = tf.Variable(tf.random_normal([5, 5, 1, 64]))
b1 = tf.Variable(tf.random_normal([64]))
w2 = tf.Variable(tf.random_normal([5, 5, 64, 64]))
b2 = tf.Variable(tf.random_normal([64]))
w3 = tf.Variable(tf.random_normal([38*38*64, 1024]))
b3 = tf.Variable(tf.random_normal([1024]))
w_out = tf.Variable(tf.random_normal([1024, 2]))
b_out = tf.Variable(tf.random_normal([2]))
def conv_layer(x,w,b):
conv = tf.nn.conv2d(x,w,strides=[1,1,1,1], padding = 'SAME')
conv_with_b = tf.nn.bias_add(conv,b)
conv_out = tf.nn.relu(conv_with_b)
return conv_out
def maxpool_layer(conv,k=2):
return tf.nn.max_pool(conv, ksize=[1,k,k,1], strides=[1,k,k,1], padding='SAME')
def model():
x_reshaped = tf.reshape(x, shape=[-1, 150, 150, 1])
conv_out1 = conv_layer(x_reshaped, w1, b1)
maxpool_out1 = maxpool_layer(conv_out1)
norm1 = tf.nn.lrn(maxpool_out1, 4, bias=1.0, alpha=0.001 / 9.0, beta=0.75)
conv_out2 = conv_layer(norm1, w2, b2)
norm2 = tf.nn.lrn(conv_out2, 4, bias=1.0, alpha=0.001 / 9.0, beta=0.75)
maxpool_out2 = maxpool_layer(norm2)
maxpool_reshaped = tf.reshape(maxpool_out2, [-1, w3.get_shape().as_list()[0]])
local = tf.add(tf.matmul(maxpool_reshaped, w3), b3)
local_out = tf.nn.relu(local)
out = tf.add(tf.matmul(local_out, w_out), b_out)
return out
model_op = model()
cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(model_op, y))
train_op = tf.train.AdamOptimizer(learning_rate=0.001).minimize(cost)
correct_pred = tf.equal(tf.argmax(model_op, 1), tf.argmax(y,1))
accuracy = tf.reduce_mean(tf.cast(correct_pred,tf.float32))
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
onehot_labels = tf.one_hot(labels, 2, on_value=1.,off_value=0.,axis=-1)
onehot_vals = sess.run(onehot_labels)
batch_size = 1
for j in range(0, 5):
print('EPOCH', j)
for i in range(0, len(data), batch_size):
batch_data = data[i:i+batch_size, :]
batch_onehot_vals = onehot_vals[i:i+batch_size, :]
_, accuracy_val = sess.run([train_op, accuracy], feed_dict={x: batch_data, y: batch_onehot_vals})
print(i, accuracy_val)
print('DONE WITH EPOCH')
除非在该请求路径上的文件系统上存在文件,否则可能会错误配置哪些会阻止IIS提供请求?
答案 0 :(得分:1)
问题是由于服务器级IIS中的配置更改导致让我们的加密工作正常。
我的工作是使用Let's Encrypt来允许我们对网站内部使用的域别名使用有效的证书,因此我们不必为证书付费。
在网站的extensionless static
files
子目录中提供/.well-known/acme-challenge/
服务的常见问题的解决方案是Move the StaticFile mapping above the ExtensionlessUrlHandler mappings。
似乎问题在于,当应用此方法时,在Extensionless Urls和IIS在Web Api路径路径中查找没有扩展名的文件之前处理静态文件,并且如果先前的模块发现了它们,则仅为后续模块提供请求正在寻找。
我还没想出如何让我们在IIS和ExtensionlessUrlHandler上加密的要求共存,但如果我这样做,我会更新这个答案。
答案 1 :(得分:-1)