C#解码javascript中的eval

c#解码js中的eval


private string Eval(string stringjs)
{
    string MyJs = "function Eval(code){code2=code.replace(/^eval/,'');return eval(code2);}";
    object[] _params = new object[1];
    _params[0] = stringjs;
    MSScriptControl.ScriptControl js = new MSScriptControl.ScriptControl();
    js.Language = "javascript";
    js.AddCode(MyJs);
    string result = js.Run("Eval", _params);//NET4.0以下为js.Run("Eval",ref _params).ToString();
    return result;
}


你可能感兴趣的:(C#解码javascript中的eval)