我可以运行ASPX并在不发出HTTP请求的情况下grep结果吗?

我怎样才能在没有URL和没有HTTP的情况下对一个简单的ASP.NET文件进行函数调用,并捕获它生成的字节流? 更多背景资料, 我需要一种模板可以在里面放一点逻辑,来渲染一些像文本文件一样的INI。 我放弃了从Java移植的库,并提出了使用ASP.NET作为模板引擎的解决方案。 (我不是用它来构建一个网站,甚至不是HTML。) 我编写了一个ASP.NET页面(没有WebForm,没有MVC),它接受XML POST,并根据一组简单但不太简单的规则生成一个长文本文件。 我从DB对象生成XML,提交到ASP页面,grep结果,它工作得很好。 但是,问题是我们想要用作WCF使用的库。 因此,我没有使用相对路径,我必须在配置中的某处存储ASP的URL,这是我不想要的。 它将托管在IIS服务器上,但不会从任何前端ASP调用(至少不是直接),并且永远不会从最终用户调用。 PS。 我原本是在为C#寻找一个简单的模板引擎,但它们太旧了,不再需要维护,文档很差,缺少集成的编辑器/调试器,太简单了,而且它们可能会说不同的语言。 PPS。 我也考虑过T4,但它在VS 2008中没有编辑器和调试器。

从javascript调用webmethod时,ASP.NET 500内部服务器出错

我试图使用AJAX调用webmethod fucntionality但无法获得适当的结果。 我搜索了我的问题并找到了许多解决方案,但那些对我没用。 请指导我做错了什么。 帮助将不胜感激。 干杯 代码片段 function checkUserNameExists() { //initialization var pagePath = window.location.pathname + “/getUsername”; var value = document.getElementById(‘control_userName’).value; var dataString = “{ ‘value’:'” + value + “‘ }”; $.ajax({ type: “GET”, url: pagePath, data: dataString, contentType: “application/json; charset=utf-8”, dataType: “json”, error: function (XMLHttpRequest, textStatus, errorThrown) { }, success: function (result) { var […]

xsd.exe使用数组中的多个元素生成c#

我有一组XML模式文件提供给我。 我无法更改XML,因为这些有时会更新。 我正在使用xsd.exe将架构文件转换为生成的c#代码。 我不能使用任何第三方工具。 其中一个XML模式文件的一部分显示如下: 当转换为c#时,我得到如下结果: [System.CodeDom.Compiler.GeneratedCodeAttribute(“xsd”, “4.0.30319.1”)] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute(“code”)] [System.Xml.Serialization.XmlTypeAttribute(Namespace = “http://abcxyz.com”)] public partial class LocationType { private object[] itemsField; private ItemsChoiceType[] itemsElementNameField; /// [System.Xml.Serialization.XmlElementAttribute(“Address”, typeof(string), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute(“City”, typeof(string), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute(“LocNum”, typeof(string), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute(“Longitude”, typeof(decimal), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlElementAttribute(“State”, typeof(LocationTypeState), Form = System.Xml.Schema.XmlSchemaForm.Unqualified)] [System.Xml.Serialization.XmlChoiceIdentifierAttribute(“ItemsElementName”)] public object[] Items […]

OWIN上的Application_PreSendRequestHeaders()

我有一个不使用OWIN中间件的应用程序,并具有以下Global.asax : public class MvcApplication : HttpApplication { protected void Application_Start() { //… } protected void Application_PreSendRequestHeaders() { Response.Headers.Remove(“Server”); } } 每次应用程序发送响应时,都会删除Server标头。 如何使用使用OWIN的应用程序执行相同操作? public class Startup { public void Configuration(IAppBuilder application) { //… } //What method do I need to create here? }

如何在ms图表中更改X轴标签的方向

嗨我在winforms应用程序中使用Ms chart控件来显示根据日期的值 我需要将x轴标签值(Dates)方向改为垂直方向 我搜索了很多属性,但我没有找到任何解决方案。 任何人都可以帮我解决这个问题 非常感谢 ….

Spintax C#…我该如何处理?

Spintax允许您旋转各种单词和句子,例如: {Hello|Hi} {World|People}! {C{#|++|}|Java} is an {awesome|amazing} language. 大括号之间的文本将随机选择以形成不同的句子。 我自己可能想出一个解决方案,但我遇到的问题是嵌套。 有时嵌套可能非常深。 处理嵌套的可能解决方案是什么? 我无法收集所需的逻辑。

为WinForm应用程序分配控制台

我使用以下代码为WinForm应用程序分配控制台。 控制台窗口成功显示,输出就在那里。 但是当我关闭控制台窗口时,我的WinForm应用程序同时关闭。 为什么? 我想保留WinForm窗口。 private void btn_to_console_Click(object sender, EventArgs e) { if (NativeMethods.AllocConsole()) { lbl_console_alloc_result.Text = “Console allocation successfully!”; IntPtr stdHandle = NativeMethods.GetStdHandle(NativeMethods.STD_OUTPUT_HANDLE); Console.WriteLine(“from WinForm to Console!”); lbl_console_alloc_result.Text = Console.ReadLine(); } else lbl_console_alloc_result.Text = “Console allocation failed!”; } [System.Runtime.InteropServices.DllImportAttribute(“kernel32.dll”, EntryPoint = “GetStdHandle”)] public static extern System.IntPtr GetStdHandle(Int32 nStdHandle); /// Return Type: BOOL->int [System.Runtime.InteropServices.DllImportAttribute(“kernel32.dll”, EntryPoint […]

Matlab和.NET 4.0数据通信

我有一个在Matlab中实现的算法,我打算将其部署为DLL,以便与.NET项目集成。 .NET项目是基于GUI的应用程序,其中一小部分包括显示从运行算法获得的结果。 我目前遇到的问题是我需要显示中间结果。 该算法非常复杂,可以运行多次迭代(由用户选择),并且在每次迭代结束时,GUI应该使用当前数据进行更新。 我现在想到的最好的解决方案是让Matlab线程充当我在C#GUI应用程序中启动的本地tcp服务器的tcp客户端。 但是,我觉得这种方法效率低下。 我想知道这是否可以通过其他方式实现。

使用委托从C#调用IronRuby

是否可以使用委托作为参数从C#调用IronRuby方法,以便yield可以工作? 以下给出了错误数量的参数(1表示0)exception。 Action action = Console.WriteLine; var runtime = Ruby.CreateRuntime(); var engine = runtime.GetEngine(“rb”); engine.Execute(@” class YieldTest def test yield ‘From IronRuby’ end end “); object test = engine.Runtime.Globals.GetVariable(“YieldTest”); dynamic t = engine.Operations.CreateInstance(test); t.test(action);

RSA:在javascript中加密密码但在C#中无法解密

我想在我的项目中应用RSA加密,但遇到了一些麻烦: 首先,我从http://www.ohdave.com/rsa/下载JavaScripts库,并添加对我的项目的引用; 其次,我已经定义了RSA对象和代码来初始化: internal RSACryptoServiceProvider Rsa { get { if (HttpContext.Cache[“Rsa”] != null) { RSACryptoServiceProvider encryptKeys = (RSACryptoServiceProvider)HttpContext.Cache[“Rsa”]; return encryptKeys; } else { return new RSACryptoServiceProvider(1024); } } set { HttpContext.Cache.Remove(“Rsa”); HttpContext.Cache.Insert(“Rsa”, value); } } public ActionResult SignUp() { this.Rsa = Security.GetRsa(); RSAParameters param= this.Rsa.ExportParameters(true); //this will bind to view TempData[“exponent”] = Util.BytesToHexString(param.Exponent); TempData[“key”] = […]