我正在使用mvc5 + c#,我通过外部登录(facebook,google,...)为我的用户提供了登录我网站的选项.
我正在尝试将Microsoft Live添加为新的提供商.但是,我没有看到任何选项来获取已连接用户的电子邮件地址.
当某个微软用户连接时,我正在获得这些声明("KEY | VALUE"):
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier | *****************
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name | test
http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider | ASP.NET Identity
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier | **************
http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name | ****************
urn:microsoftaccount:id | ****************
urn:microsoftaccount:name | ****************
urn:microsoftaccount:access_token | **************************************************************
Run Code Online (Sandbox Code Playgroud)
有什么选项可以使用此信息获取用户的电子邮件地址吗?
我在C#(vs2013)上写了一个小型POC应用程序(控制台应用程序),它使得:主机和客户端.
主机端的代码:
string url = "http://*:8900/";
using (WebApp.Start(url))
{
Console.WriteLine("Server running at " + url);
lock (just4lock)
Monitor.Wait(just4lock);
}
Run Code Online (Sandbox Code Playgroud)
只有当我使用"以管理员身份运行"运行我的(控制台)应用程序时,它才有效.
好的,现在我想将此代码移到我的Windows服务应用程序中.当我在Windows服务上运行相同的主机代码时,我收到此错误:
An unhandled exception of type 'System.MissingMemberException' occurred in Microsoft.Owin.Hosting.dll
Additional information: The server factory could not be located for the given input: Microsoft.Owin.Host.HttpListener
Run Code Online (Sandbox Code Playgroud)
我的服务以"本地系统帐户"运行.我没有看到任何让它"以管理员身份运行"的选项.
您是否知道如何在没有管理员的情况下使SignalR自托管工作?
我怎么能让这个Windows服务以管理员身份运行?
谢谢!
我有一个很多李的ul元素.某些线条(li)以黄色背景突出显示.
我想在右边框添加一个三角形.此三角形应该看起来像指向文本的箭头.
像这样的东西:

我试图用右边框绘制这个三角形,但这并没有给我正确的形状.
<ul>
<li>not highlighted</li>
<li>not highlighted</li>
<li class="highlighted">HIGHLIGHTED</li>
<li>not highlighted</li>
</ul>
<style>
.highlighted {
border-right: 20px solid red;
}
</style>
Run Code Online (Sandbox Code Playgroud)
Please give a notice on the that one li can contain more the one line, so the height of the line can be changed. Arrow with fixed height (of one line) is good enough.
Is this possible? If yes, how?
我只是创建一个web-api项目(基于带C#的ASP.NET).VS正在使用它的演示应用程序创建这个空应用程序,以展示他的功能.这个演示一切正常.
作为演示代码的一部分,您将在"App_Start/Startup.Auth.cs"文件中使用此块:
// Configure the application for OAuth based flow
PublicClientId = "self";
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
Run Code Online (Sandbox Code Playgroud)
好.现在,让我们假设身份验证机制运行良好.我想向WebAPI添加关于此"/ Token"页面的文档.但是,由于此页面是由代码创建的,因此WebAPI文档机制无法将其识别为文档的一部分.那么,我的用户应该如何知道如何登录我的应用程序?
我可以做些什么来在我的自动生成的API文档中添加这个"/ Token"页面?
谢谢.
我在C#上运行一个C#MVC网站很长一段时间.最近,我在记录器数据中注意到了这条日志消息:
System.IO.IOException: The network name cannot be found.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.Directory.EnumerateFiles(String path)
at System.Web.WebPages.Deployment.WebPagesDeployment.AppRootContainsWebPagesFile(String path)
at System.Web.WebPages.Deployment.PreApplicationStartCode.OnChanged(String key, Object value, CacheItemRemovedReason reason)
at System.Web.Caching.CacheEntry.CallCacheItemRemovedCallback(CacheItemRemovedCallback callback, CacheItemRemovedReason reason)
Run Code Online (Sandbox Code Playgroud)
我也知道:
ASP.global_asax文件中抛出此异常.如您所见,此调用堆栈中没有任何内容存在于我的代码中.因此,我不知道如何重复这个或解决这个问题.
你怎么建议我解决这个问题?任何提示都会有所帮助.
我在C#中使用asp.net core v2.1,并做了一个小型网站。该网站具有ExceptionsTracker捕获所有未处理异常的功能。
internal class ExceptionTracker : ExceptionFilterAttribute
{
public override void OnException(ExceptionContext context)
{
// ...
string httpRequestInformation;
try
{
httpRequestInformation = context.HttpContext.Request.ToString(); // The problem here.
}
catch (Exception)
{
httpRequestInformation = string.Empty;
}
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
其背后的主要思想是将所有异常写入日志并能够在开发时重现它(运行产生该异常的相同查询)。
当我使用以前的.NET Framework(v4.6)编写此行时
context.HttpContext.Request.ToString(),返回值是一个字符串,其中包含来自请求的所有信息(请求的URL,标头,正文等)。当我使用.net core时,返回值为
Microsoft.AspNetCore.Http.Internal.DefaultHttpRequest
Run Code Online (Sandbox Code Playgroud)
您有更好的解决方案,然后手动构造此字符串吗?
谢谢!
根据@kennyzx的建议,我对方法进行了简短的扩展以解决此问题。
public static class HttpRequestExtensions
{
public static string GetDetails(this HttpRequest request)
{
string baseUrl = $"{request.Scheme}://{request.Host}{request.Path}{request.QueryString.Value}";
StringBuilder sbHeaders = new StringBuilder();
foreach (var header in request.Headers)
sbHeaders.Append($"{header.Key}: …Run Code Online (Sandbox Code Playgroud) 我的命名空间很少有部署。其中一个部署具有特定标签 ( my-label=yes)。我想要获得带有此标签的所有 pod。
这就是它的完成方式kubectl:
kdev get pods -l my-label=yes
Run Code Online (Sandbox Code Playgroud)
它正在工作。
现在我想用 Kubernetes API 来实现。这是我得到的最接近的点:
curl https://kubernetes.default.svc/api/v1/namespaces/XXX/pods --silent --header "Authorization: Bearer $TOKEN" --insecure
Run Code Online (Sandbox Code Playgroud)
此命令获取命名空间中的所有 pod。我想将结果过滤到具有此请求标签的所有 pod。怎么做?
更广泛的问题:是否可以将 kubectl 命令“翻译”为 REST API 调用?
我想开始使用Azure Service Fabric技术.
我正在根据此文档工作并安装最新的SDK.安装完成后,我打开了PowerShell("以管理员身份运行")命令行窗口并写下这些行:
# Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Scope CurrentUser
# cd "$env:ProgramW6432\Microsoft SDKs\Service Fabric\ClusterSetup"
# .\DevClusterSetup.ps1
Run Code Online (Sandbox Code Playgroud)
作为答案,得到了这个错误:
Cleaning existing cluster ...
NOTE: If this powershell command window exits, please re-run the script in a new powershell command window.
Stopping service FabricHostSvc. This may take a few minutes...
Removing cluster configuration
Remove node configuration succeeded
Cleaning existing certificates
Stopping all logman sessions
Cleaning log and data folder, the powershell window may close automatically.
ClusterPath not provided, will …Run Code Online (Sandbox Code Playgroud) 我使用 SQL Server 数据库来存储很长的 Unicode 字符串。该字段来自类型“ntext”,理论上应限制为 2^30 个 Unicode 字符。
从MSDN 文档:
正文
可变长度 Unicode 数据,最大字符串长度为 2^30 - 1 (1,073,741,823) 字节。存储大小(以字节为单位)是输入的字符串长度的两倍。ntext 的 ISO 同义词是国家文本。
我做了这个测试:
生成 50,000 个字符的字符串。
运行更新 SQL 语句
UPDATE [table] SET Response='... 50,000 个字符串...' WHERE ID='593BCBC0-EC1E-4850-93B0-3A9A9EB83123'
检查结果 - 最后实际存储在字段中的内容。
结果是字段 [Response]仅包含43,679 个字符。字符串末尾的所有字符都被丢弃了。
为什么会发生这种情况?我该如何解决这个问题?
如果这真的是这种数据类型(ntext)的容量限制,还有哪一种数据类型可以存储更长的Unicode字符串?
我有一个分布式应用程序,它与Azure存储队列共享负载.为了验证一切正常,我写了一个小应用程序,每10分钟运行一次并检查队列中有多少项.如果该数字高于阈值,请向我发送通知消息.
这就是我在所有队列中运行的方式:
Dictionary<string, int> dic = new Dictionary<string, int>();
foreach (CloudQueue queue in QueuesToMonitor)
{
queue.FetchAttributes();
dic.Add(queue.Name, queue.ApproximateMessageCount.HasValue ? queue.ApproximateMessageCount.Value : -1);
}
Run Code Online (Sandbox Code Playgroud)
这段代码工作正常,但它也计算隐藏的消息.我想从计数中排除这些消息(因为那些任务还没有准备好执行).
例如,我检查了我的一个队列并得到了579个项目在队列中的答案.但是,实际上没有可见的物品.我用Azure Storage Explorer验证了这一点:

如何只计算队列中的可见项?
c# ×6
asp.net ×3
asp.net-mvc ×2
azure ×2
.net-core ×1
asp.net-core ×1
css ×1
css-shapes ×1
html ×1
html5 ×1
ioexception ×1
kubectl ×1
kubernetes ×1
ntext ×1
powershell ×1
signalr ×1
sql ×1
sql-server ×1
sql-update ×1