如何使用Asp.Net核心中的WebListener与2个服务共享端口。
我尝试注册URL前缀,如下所示
netsh http add urlacl url=http://machinename:8080/Service1 user=xxx listen=yes
netsh http add urlacl url=http://machinename:8080/Service2 user=xxx listen=yes
但是在使用相同的8080端口启动第二个服务时,我遇到了错误。
fail: Microsoft.Net.Http.Server.WebListener[0]
Start
Microsoft.Net.Http.Server.WebListenerException (0x80004005): The process cannot
access the file because it is being used by another process
at Microsoft.Net.Http.Server.UrlGroup.RegisterPrefix(String uriPrefix, Int32
contextId)
at Microsoft.Net.Http.Server.UrlPrefixCollection.RegisterAllPrefixes(UrlGroup
urlGroup)
at Microsoft.Net.Http.Server.WebListener.Start()
这是代码
string baseAddress = "http://machinename:8080/Service1";
var builder = new WebHostBuilder()
.UseWebListener(options =>
{
options.ListenerSettings.Authentication.Schemes =
Microsoft.Net.Http.Server.AuthenticationSchemes.NTLM;
options.ListenerSettings.Authentication.AllowAnonymous = true;
})
.UseContentRoot(pathToContentRoot)
.UseStartup<Startup>()
.UseUrls(baseAddress);
host = builder.Build();
答案 0 :(得分:0)
<table class="variations" cellspacing="0">
<tbody>
<?php foreach ( $attributes as $attribute_name => $options ) : ?>
<tr>
<td class="label"><label for="<?php echo esc_attr( sanitize_title( $attribute_name ) ); ?>">
<?php echo wc_attribute_label( $attribute_name ); // WPCS: XSS ok. ?></label></td>
<td class="value">
<?php
wc_dropdown_variation_attribute_options( array(
'options' => $options,
'attribute' => $attribute_name,
'product' => $product,
) );
echo end( $attribute_keys ) === $attribute_name ? wp_kses_post( apply_filters( 'woocommerce_reset_variations_link', '<a class="reset_variations" href="#">' . esc_html__( 'Clear', 'woocommerce' ) . '</a>' ) ) : '';
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
使用此 链接:https://github.com/aspnet/HttpSysServer/blob/master/samples/SelfHostServer/Startup.cs