Asp.net Microsoft.AspNet.FriendlyURL替代NuGet软件包

Asp.net Microsoft.AspNet.FriendlyURL替代NuGet软件包,asp.net,vb.net,url,nuget,Asp.net,Vb.net,Url,Nuget,此NuGet软件包FriendlyURL仅支持C#Web应用程序。但是,我现在正在构建一个VB Web应用程序,而该软件包不适合我的情况。那么,是否有类似的软件包支持VB Web App,并具有与FriendlyURL相同的行为 在Identity Server 4中,我对来自客户端的请求进行了配置,如下所示。请注意,AllowedRedirectURI为“http://test.mydomain:5001/signincallback“因为Identity Server 4是基于MVC模型构建

此NuGet软件包FriendlyURL仅支持C#Web应用程序。但是,我现在正在构建一个VB Web应用程序,而该软件包不适合我的情况。那么,是否有类似的软件包支持VB Web App,并具有与FriendlyURL相同的行为

在Identity Server 4中,我对来自客户端的请求进行了配置,如下所示。请注意,AllowedRedirectURI为“http://test.mydomain:5001/signincallback“因为Identity Server 4是基于MVC模型构建的

{
  "ClientId": "test.mydomain.com",
  "ClientName": "My Client App",
  "AllowedRedirectUris": [
    "http://test.mydomain:5001/signincallback"
  ],
  "SubjectId": "anonymous",
  "RequestedScopes": "",
  "Raw": {
    "client_id": "test.mydomain.com",
    "response_type": "code id_token",
    "scope": "openid profile",
    "redirect_uri": "http://test.mydomain:5001/signincallback",
    "state": "873a0bbf6755485cafb112e74f3a81b8",
    "nonce": "783e367fb17b42948211af2cfa68fbbb",
    "acr_values": "tenant:e443e8f8-74f7-42b2-9304-b247cf560f79",
    "response_mode": "form_post"
  }
}
在我的客户端应用程序(VB Webform应用程序-它不是MVC)中,我创建了一个与上述格式匹配的请求:

Private ReadOnly _authority As String
    Private ReadOnly _clientId As String
    Private ReadOnly _tenantId As String

    Protected Sub New()
        _authority = ConfigurationManager.AppSettings("auth:authority")
        _clientId = ConfigurationManager.AppSettings("auth:clientId")
        _tenantId = ConfigurationManager.AppSettings("auth:tenantId")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        Dim hostUrl = $"{Me.Request.Url.Scheme}://{Me.Request.Url.Authority}"
        Dim hostUri = New Uri(hostUrl, UriKind.Absolute)
        Dim redirectUri = New Uri(hostUri, "signincallback").ToString()
        Dim client = New HttpClient()
        Dim disco = client.GetDiscoveryDocumentAsync(_authority).Result
        Dim state = Guid.NewGuid().ToString("N")
        Dim nonce = Guid.NewGuid().ToString("N")
        SetTempCookie(state, nonce)
        Dim authorizeUrl = New RequestUrl(disco.AuthorizeEndpoint).CreateAuthorizeUrl(clientId:=_clientId, responseType:=OidcConstants.ResponseTypes.CodeIdToken, scope:="openid profile", redirectUri:=redirectUri, state:=state, nonce:=nonce, acrValues:=$"tenant:{_tenantId}", responseMode:=OidcConstants.ResponseModes.FormPost)
        Response.Redirect(authorizeUrl)
    End Sub

    Private Sub SetTempCookie(ByVal state As String, ByVal nonce As String)
        Dim tempId = New ClaimsIdentity(AuthenticationTypes.TemporaryCookieAuthentication)
        tempId.AddClaim(New Claim("state", state))
        tempId.AddClaim(New Claim("nonce", nonce))
        Request.GetOwinContext().Authentication.SignIn(tempId)
    End Sub
结果是我的客户端应用程序可以加载Identity Server 4登录页面。登录到该页面后,它无法加载到“signincallback.aspx”页面

根本原因是,我的客户端应用程序是VB Webform,而不是MVC。因此,上面的AlloweredRedirectUris将重新加载URL“http://test.mydomain:5001/signincallback“它不明白这是什么。 如果我输入URL,它就可以加载页面


我尝试使用NuGet FriendyUrls将无扩展URL自动解析为基于ASP.NET文件的处理程序(例如ASPX页面),以告诉我的客户端URL“http://test.mydomain:5001/signincallback“应理解为”http://test.mydomain:5001/signincallback.aspx“,但它不起作用。

它应该与VB.NET一起工作,即使没有显示该语言的文档。安德烈·莫尔顿:谢谢你的评论。请看我的更新上面。