ASP.Net:在项目中创建处理程序
抱歉,如果这是一个愚蠢的问题。我想在我的项目中创建一个 HTTP 处理程序。为此,我创建了一个新类,并尝试实现 IHttpHandler。
每次执行此操作时,我都会收到错误“预期语句结束”。
我知道通常您可以创建一个新的类库并创建一个类来实现处理程序。但为什么在现有的 Web 项目中无法做到这一点呢?
WT
Sorry if this is a stupid question. I want to create an HTTP handler within my project. To do this, I created a new class, and tried to implement IHttpHandler.
Each time I do this, I get the error 'End of statement expected'.
I know that normally you can create a new class library and create a class to implement a handler. But why is it not possible to do this in an existing web project?
WT
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个名为 ashx 或通用处理程序的新对象。从那里您可以输入服务器端代码并输出您想要给出的确切结果。老实说,虽然我会使用 WCF,但它要容易得多,而且您可以以您喜欢的任何数据类型吐出数据。
Create a new object called an ashx or Generic Handler. From there you can put in server side code and output the exact result you would like to dish out. Honestly though I would use WCF though, its a lot easier and you can spit out the data in any data type you like.
尽管将其放入 Web 项目中不是最佳实践,但您是否在 web.config 中正确引用了它,以便它知道在 App_Code 文件夹中查找?
Even though its not a best practice to put it in the web project, are you referencing it in the web.config correctly, so it knows to look in the App_Code folder?