我无法在任何地方找到如何在ASP.NET 4.5 webforms应用程序中设置OAuth2 redirect_uri.默认情况下它设置为localhost,当然我从谷歌得到这个错误:
The redirect URI in the request: http://localhost:3884/signin-google did not
match a registered redirect URI
Run Code Online (Sandbox Code Playgroud)
这来自Facebook:
Given URL is not allowed by the Application configuration.: One or more of the
given URLs is not allowed by the App's settings. It must match the Website URL
or Canvas URL, or the domain must be a subdomain of one of the App's domains.
Run Code Online (Sandbox Code Playgroud)
我从我的网站域(而不是localhost)收到此错误.
我和同事都负责为Azure表存储找到连接重试逻辑.经过一番搜索,我发现这个非常酷的Enterprise Library套件包含了Microsoft.Practices.TransientFaultHandling名称空间.
下面的几个代码示例,我结束了创建一个Incremental重试策略,我们的包装与存储调用之一retryPolicy的ExecuteAction回调处理程序:
/// <inheritdoc />
public void SaveSetting(int userId, string bookId, string settingId, string itemId, JObject value)
{
// Define your retry strategy: retry 5 times, starting 1 second apart, adding 2 seconds to the interval each retry.
var retryStrategy = new Incremental(5, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));
var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(StorageConnectionStringName));
try
{
retryPolicy.ExecuteAction(() =>
{
var tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference(SettingsTableName);
table.CreateIfNotExists();
var entity = new Models.Azure.Setting
{
PartitionKey = …Run Code Online (Sandbox Code Playgroud) 我全新到Visual Studio 2012和MVC 4,和我一直在工作SimpleMembershipProvider通过WebMatrix.WebData库.
我想将Facebook作为外部登录源整合,但现在不是必需的.然而,为了获得一个体面的感觉,我一直在遵循这里找到的教程和指南 - http://www.asp.net/mvc/tutorials/mvc-4/using-oauth-providers-with -mvc.
我的问题 :
如果已使用以下方法创建用户:
WebSecurity.CreateUserAndAccount(model.Email, model.Password);
WebSecurity.Login(model.Email, model.Password);
Run Code Online (Sandbox Code Playgroud)
oAuthMemebership如果他们选择使用他们的Facebook凭据而不是他们在首次注册时创建的电子邮件和密码,他们可以在未来"升级"到帐户吗?
我在指南或其他地方找不到这个问题的明确答案,所以我希望有人可以澄清这个过程是如何起作用的.
我有这个我正在使用的代码块:
// get the collection of librarys from the injected repository
librarySearchResults = _librarySearchRepository.GetLibraries(searchTerm);
// map the collection into a collection of LibrarySearchResultsViewModel view models
libraryModel.LibrarySearchResults =
librarySearchResults.Select(
library =>
new LibrarySearchResultsViewModel
{
Name = library.Name,
Consortium = library.Consortium,
Distance = library.Distance,
NavigateUrl = _librarySearchRepository.GetUrlFromBranchId(library.BranchID),
BranchID = library.BranchID
}).ToList();
Run Code Online (Sandbox Code Playgroud)
所有这一切都是取结果GetLibraries(searchTerm),返回一个LibrarySearchResult对象列表,并将它们映射到一个列表LibrarySearchResultsViewModel.
虽然这适用于小型结果集,但一旦我进入1000,它真的开始拖动,在完成转换之前大约需要12秒.
我的问题 :
由于我在这里使用分页,我实际上只需要显示在大型结果集中返回的一小部分数据.有没有利用类似的方式Take()或者GetRange(),这样的转换仅发生于我需要显示的记录?在1,000条记录中,我只想获取20到40条记录,并将它们转换为视图模型.
我也是关于改进或重构此代码的任何建议.
我可能过度思考了这一点,但我正在寻找比现在更优雅的东西.
我调用了这个方法CalculatePercentageTrend,它接受long"previous"值和"current"值.目前的情况如下:
public static string CalculatePercentageTrend(long previousValue, long currentValue)
{
var trend = "0.00%";
// calculate percentage increase
if (previousValue < currentValue)
{
if (previousValue != 0)
{
var difference = previousValue - currentValue;
var pctDecrease = (double)(difference / previousValue) * 100;
trend = pctDecrease.ToString("P");
}
else
{
trend = currentValue.ToString("P");
}
}
// calculate percentage decrease
else if (currentValue < previousValue)
{
if (previousValue != 0)
{
var difference = currentValue - previousValue;
var pctIncrease …Run Code Online (Sandbox Code Playgroud) 我们正在使用New Relic来监控我们的许多Web应用程序.
这为我们提供了可用性监控,它允许您在应用程序中指定一个特定的端点,可以"ping"以确保您的应用程序"活着" - 显然非常有用,但是有一个小问题.
我注意到我从New Relic获得的ping请求并不总是a POST,它有时是a GET,这会导致我的端点抛出一个405 HttpStatusMessage : Method not allowed.
没问题 - 我想我只是配置我的端点来响应两者:
[Route("status")]
public class StatusController : ApiController
{
public IHttpActionResult Post()
{
return Ok();
}
public IHttpActionResult Get()
{
return Ok();
}
}
Run Code Online (Sandbox Code Playgroud)
现在被授予,这确实有效,但对于这样一个简单的任务来说似乎很麻烦.
我很好奇 - 有没有更干净或更好的方法,我还没有看到呢?
目前,我正在通过PowerShell的自动化计划任务的创造,我使用的New-ScheduledTaskAction,New-ScheduledTaskTrigger和Register-ScheduledTask命令。现在,我有一些作业需要在以下条件下运行:
虽然TechNet文档的New-ScheduledTaskTrigger命令指定Daily和Weekly时间跨度参数,我没有看到一个Monthly,这是定义上述的运行时间是至关重要的。
在我使用 Powershell 的几年中,我想不出一个实例可以通过标准 UI 界面执行某些操作,而使用可用命令之一无法完成这些操作。
这只是在这里不可用,还是我错过了什么?
更新 #1
我只是偶然发现了这个SuperUser question,它看起来很有希望,但引用了 PSV3 而不是 PSV4 - 打算试一试并报告。
我使用转换器将vb更改为c#,其中一行原来是:
Dim roles = System.Web.Security.Roles.GetAllRoles()
Dim roleNames() As String = roles.Where(Function(x) x.ToLower() <> "Admin").ToArray()
Run Code Online (Sandbox Code Playgroud)
当转换返回时,我得到:
dynamic roles = System.Web.Security.Roles.GetAllRoles();
string[] roleNames = roles.Where(x => x.ToLower() != "Admin").ToArray();
Run Code Online (Sandbox Code Playgroud)
然后抛出错误:
如果不首先将lambda表达式转换为委托或表达式树类型,则不能将lambda表达式用作动态分派的操作的参数.
我尝试了几种不同的方式和几种不同的转换器,但我没有得到任何不同的结果.
为什么它在vb中工作正常,而不是在c#中如果转换是正确的?