试图访问HttpContext.Current一个方法调用回来,我可以修改一个Session变量,但我收到的异常HttpContext.Current是null.当_anAgent对象触发它时,异步触发回调方法.
我的代码的简化版本如下所示:
public partial class Index : System.Web.UI.Page
protected void Page_Load()
{
// aCallback is an Action<string>, triggered when a callback is received
_anAgent = new WorkAgent(...,
aCallback: Callback);
...
HttpContext.Current.Session["str_var"] = _someStrVariable;
}
protected void SendData() // Called on button click
{
...
var some_str_variable = HttpContext.Current.Session["str_var"];
// The agent sends a message to another server and waits for a call back
// which triggers …Run Code Online (Sandbox Code Playgroud) 使用Owin Security,我试图让API有2种身份验证方法.
context变量(OAuthGrantResourceOwnerCredentialsContext)中是否有一个属性可以让我访问客户端的IP地址,向API发送auth令牌的初始请求?
我的auth方法的基本条带如下所示:
public override async Task GrantResourceOwnerCredentials(
OAuthGrantResourceOwnerCredentialsContext context)
{
await Task.Run(() =>
{
var remoteIpAddresss = context.Request.RemoteIpAddress;
var localIpAddress = context.Request.LocalIpAddress;
// ... authenticate process goes here (AddClaim, etc.)
}
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解remoteIpAddress和localIpAddressAPI(即API的托管位置).我如何知道请求从哪个IP地址(和端口)发送?
客户是否需要自己发送此信息?
我应该在auth路径中添加额外的参数吗?(除了典型username,password,grant_type)?
我正在使用Entity Framework和一个大型数据库(由200多个表组成).
尝试创建一个返回DbSet<T>特定表T(即类,可以是TableA)的泛型方法.
使用实体数据模型(自动)创建的实体类如下所示:
public partial class sqlEntities : DbContext
{
public virtual DbSet<TableA> TableA { get; set; }
public virtual DbSet<TableB> TableB { get; set; }
public virtual DbSet<TableC> TableC { get; set; }
... // other methods
}
Run Code Online (Sandbox Code Playgroud)
我的主要课程是这样的
public class TableModifier
{
// Should return first 10 elements from a table of that type T
public IQueryable<T> GetFromDatabase<T>() where T : EntityObject
{
try
{
using (sqlEntities ctx = new sqlEntities()) …Run Code Online (Sandbox Code Playgroud) 嗨,我正在尝试让jQuery UI自动完成小部件工作,以便它搜索来自我的数组的多个属性的匹配(不仅仅是默认情况下它的一个).
我已经搞乱了他们的例子,但是我仍然不确定如何解决这个问题.
这是我的数组格式 script
var projects = [
{
value: "jquery",
label: "jQuery",
desc: "the write less, do more, JavaScript library",
other: "9834275 9847598023 753425828975340 82974598823"
},
{
value: "jquery-ui",
label: "jQuery UI",
desc: "the official user interface library for jQuery",
other: "98 83475 9358 949078 8 40287089754 345 2345"
},
{
value: "sizzlejs",
label: "Sizzle JS",
desc: "a pure-JavaScript CSS selector engine",
other: "49857 2389442 573489057 89024375 928037890"
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找的是,如果你输入"write",第一个元素应该在自动完成中弹出,同样如果你输入"jq",前两个元素应该弹出.
根据文件:
数组:数组可用于本地数据.有两种支持的格式:
字符串数组: …
我正在使用jsPlumb.我有.project容纳.taskdiv的容器.这些.taskdiv是jsPlumb连接的源/目标.该.project容器是可拖动.
在创建.taskdiv(使用jQuery创建)时,会为div分配源/目标属性:
Run Code Online (Sandbox Code Playgroud)// Makes the task div a possible target (i.e. connection can be dragged to) jsPlumb.makeTarget(newState, { anchor:["Continuous", { faces:["left", "right"] } ] }); // Makes the task div a possible source (i.e. connection can be dragged from) jsPlumb.makeSource(newState, { anchor:["Continuous", { faces:["left", "right"] } ] });
凡.task为newState
Run Code Online (Sandbox Code Playgroud)var newState = $('<div>').attr('id', id).addClass('task')
现在要删除一个任务,我有一个静态按钮,它只是分离与该任务的所有连接并将其删除:
Run Code Online (Sandbox Code Playgroud)$('#removetask1').click(function(e) { jsPlumb.detachAllConnections($('#task1')); $('#task1').remove(); //jsPlumb.repaintEverything(); })
task …
我有一个Apex类(SalesForce中的一个类),可以调用REST Web服务.
public class WebServiceCallout
{
@future (callout=true)
public static void sendNotification(String aStr)
{
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('http://xx.xxx.xxx.xx:41000/TestService/web/test');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(aStr); // I want to read this in the web service
try
{
res = http.send(req);
}
catch(System.CalloutException e)
{
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
}
}
Run Code Online (Sandbox Code Playgroud)
REST Web服务(C#,WCF)如下所示:
public interface ITestService
{
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现WCF Rest服务而不修改App.config文件.
我的服务界面如下所示:
[ServiceContract]
public interface IService
{
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "/teststr/?string={aStr}")]
string TestString(string aStr);
}
Run Code Online (Sandbox Code Playgroud)
服务实现非常基础:
public class TestService : IService
{
public string TestString(string aStr = null)
{
Console.WriteLine("The Test() method was called at {0}"
+ "\n\rThe given string was {1}\n\r"
, DateTime.Now.ToString("H:mm:ss")
, aStr);
return aStr;
}
}
Run Code Online (Sandbox Code Playgroud)
我的主要程序运行一切:
// Step 1 Create a URI to serve as the base address.
Uri baseAddress …Run Code Online (Sandbox Code Playgroud) 我试图避免在使用jsPlumb 时有重复的连接(2 个连接具有相同的源和目标)。有没有办法在不必修改 jsPlumb.js 本身的情况下做到这一点?
http://jsfiddle.net/uQdfq/
(从拖动task1到task3 两次)
我不想像 ( 1 )那样有添加特定端点的限制。
我的.tasks 在被调用时被定义为可能的目标/源 - 即整个 div 可以是源/目标,而不仅仅是某个端点:
addTask($('#project1'), 'task' + 1);
Run Code Online (Sandbox Code Playgroud)
函数本身:
// Adds a task div to the specific project
function addTask(parentId, id) {
var newState = $('<div>').attr('id', id).addClass('task')
// A title for the task
var title = $('<div>').addClass('title').text(id);
newState.append(title);
$(parentId).append(newState);
// Makes the task div a possible target (i.e. connection can be dragged to)
jsPlumb.makeTarget(newState, {
anchor: 'Continuous'
}); …Run Code Online (Sandbox Code Playgroud) c# ×5
jquery ×3
wcf ×3
.net ×2
javascript ×2
jsplumb ×2
rest ×2
asp.net ×1
asynchronous ×1
generics ×1
jquery-ui ×1
owin ×1
salesforce ×1
web-services ×1