你怎么在asp.net中输出的是原始的JavaScript [英] How do you output raw javascript in asp.net

查看:107
本文介绍了你怎么在asp.net中输出的是原始的JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想输出原始的JavaScript来一个aspx响应。使用的Response.Write失败,因为使用JavaScript一起,它转储所有其他的asp.net的东西在页面,例如:

I would like to output raw javascript to an aspx response. Using response.write fails because along with the javascript, it dumps all of the other asp.net stuff in the page, for example:

...
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTAxODk4MjA3OWRk9jVlI2KaQPiVjEC+P0OPYGV74vKjJQZuwD6OaHhb+U0=" />
...

反正是有根本输出原始文本的输出,而不必在页面上所有其他的asp.net的东西?我试图使用页面如下:

Is there anyway to simply output raw text to the output without having all of the other asp.net stuff on the page? I am trying to use the page as follows:

<script src="mypage.aspx"></script> 

如果本页面包含此激发了aspx页面的JavaScript,但镀铬不喜欢它的原因很明显......它预计的JavaScript,但它越来越的JavaScript +标记+ .NET注入的东西。

Where this page contains the javascript this triggers off the aspx page, however chrome doesn't like it for obvious reasons... it expects javascript, but it is getting javascript + markup + .NET injected stuff.

为什么我这样做,请没有评论!对工作非常具体的问题。

Please no comments on why I am doing this! Working on very specific problem.

推荐答案

使用.ashx的 通用处理器 。然后你可以设置 context.Response.ContentType =文/ JavaScript的,只使用的Response.Write

Use .ashx Generic Handler. Then you can set context.Response.ContentType = "text/javascript" and just use Response.Write

这篇关于你怎么在asp.net中输出的是原始的JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆