标签: response

在C#中调用Response.End()后重定向到另一个页面

我正在将webview导出为ex​​cel,在Web应用程序中使用.Net 4.0,页面加载,需要生成文件,然后将页面重定向到调用页面.我遇到了问题,因为我导出到excel的代码如下:

gvSummary.Style.Add("font-size", ".6em");
    Response.Clear();
    string attachment = "attachment; filename=filename.xls";
    Response.ClearContent();
    Response.AddHeader("content-disposition", attachment);
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    StringWriter sw = new StringWriter();
    HtmlTextWriter htw = new HtmlTextWriter(sw);
    gvSummary.GridLines = GridLines.Horizontal;
    gvSummary.RenderControl(htw);
    Response.Write(sw.ToString());
    Response.End();
Run Code Online (Sandbox Code Playgroud)

我知道如果我在.End()之前放置Response.Redirect(),我将被重定向但是文件永远不会生成,如果我在.End()之后放置Response.Redirect()我得到文件但没有重定向.

上面编写的代码在生成文件时效果很好,但是在生成文件之后,我仍然看不到我的加载动画,因为我无法突破页面.有任何想法吗?

c# gridview response.redirect web-applications response

6
推荐指数
1
解决办法
1万
查看次数

是否有一个java实用程序来生成http多部分响应?

我正在构建一个返回多部分响应的Web服务.我知道构建多部分响应的格式; 如果我找不到现有的工具,我会建立自己的工具.

也许我只需要帮助我的google-foo.我发现的一切都是关于POST或消费多部分消息.没有关于产生多部分回复的信息.

java http response multipart

6
推荐指数
2
解决办法
4524
查看次数

服务器友好的慢板.可能?

如何实现一个不会成为我们网站DoS工具的slowban

问题是服务http响应的故意延迟将使服务器资源忙(Web服务器线程和可能的其他子系统).

response denial-of-service

6
推荐指数
1
解决办法
307
查看次数

Jedis中的响应对象 - 抛出ClassCastException

在Jedis中使用Response Object,抛出ClassCastException.当我使用管道时,我无法从Redis获得任何价值.请帮忙.我正在使用Jedis 2.1.0

public class JedisPipeline {    
    public static void main(String args[]){
        final JedisPool pool = new JedisPool(new JedisPoolConfig(), "127.0.0.1", 6379);
        Jedis jedis = pool.getResource();
        Pipeline pipeline = jedis.pipelined();
        pipeline.multi();
        HashMap<String,String> map = new HashMap<String,String>();
        map.put("50", "50");
        pipeline.hmset("Id",map);
        Response <Long> incr = pipeline.hincrBy("Id", "100", 100);
        Response<Map<String,String>> map1 = pipeline.hgetAll("Id");
        pipeline.exec();
        List<Object> results = pipeline.syncAndReturnAll();
        System.out.println(results);
        System.out.println( incr.get());
        System.out.println( map1.get());
        pool.returnResource(jedis);
        pool.destroy();
    }
}

Exception in thread "main" java.lang.ClassCastException: [B cannot be cast to java.lang.Long
    at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:45)
    at redis.clients.jedis.BuilderFactory$4.build(BuilderFactory.java:48)
    at redis.clients.jedis.Response.get(Response.java:27) …
Run Code Online (Sandbox Code Playgroud)

java pipeline sync response jedis

6
推荐指数
1
解决办法
2098
查看次数

RestEasy - Jax-rs - 在响应正文中发送自定义对象

如何在响应中发送自定义对象.我只想要从我的对象打印的值.

可以说我有一个类型的对象Person.我试图像这样发送REST响应体.

  ResponseBuilder response = Response.ok().entity(personObj);
  return response.build();
Run Code Online (Sandbox Code Playgroud)

但我得到500错误.也试过这个:

  ResponseBuilder response = Response.status(Status.OK).entity(personObj);
  return response.build();
Run Code Online (Sandbox Code Playgroud)

同样的错误.

尝试将内容类型设置为text/xml.没用 我在这里错过了什么?我试过谷歌搜索.但那里没有很多例子,尤其是自定义对象;

如果我只是将一个字符串传递给entity()方法,它返回正常.

java rest response jax-rs resteasy

6
推荐指数
1
解决办法
1万
查看次数

ASP.NET Web API从响应中删除HttpError

我正在使用Microsoft ASP.NET Web API构建RESTful服务.

我的问题涉及Web API在出现问题时返回给用户的HttpErrors(例如400 Bad Request或404 Not Found).

问题是,我不希望得到系列化HttpError响应内容,因为它有时会提供太多的信息,因此它违反了OWASP安全规则,例如:

请求:

http://localhost/Service/api/something/555555555555555555555555555555555555555555555555555555555555555555555
Run Code Online (Sandbox Code Playgroud)

作为回复,我当然得到400,但有以下内容信息:

{
 "$id": "1",
 "Message": "The request is invalid.",
 "MessageDetail": "The parameters dictionary contains a null entry for parameter 'id'  of non-nullable type 'System.Int32' for method 'MyNamespaceAndMethodHere(Int32)' in 'Service.Controllers.MyController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter."
}
Run Code Online (Sandbox Code Playgroud)

这样的事情不仅表明我的WebService基于ASP.NET WebAPI技术(也不是那么糟糕),而且还提供了有关我的命名空间,方法名称,参数等的一些信息.

我试图在Global.asax中设置IncludeErrorDetailPolicy

GlobalConfiguration.Configuration.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Never;
Run Code Online (Sandbox Code Playgroud)

是的,这确实很好,现在结果不包含MessageDetail部分,但仍然,我根本不想得到这个HttpError.

我还构建了自定义DelegatingHandler,但它也影响了我自己在控制器中生成的400和404,我不想发生这种情况.

我的问题是:是否有任何方便的方法来摆脱响应内容中的序列化HttpError?所有我希望用户回复他的错误请求是响应代码.

asp.net response http-error asp.net-web-api

6
推荐指数
1
解决办法
1208
查看次数

Python中的IIR响应

我有一个与这篇文章直接相关的新问题- 在Python中构建我有一个具有给定特征的二阶IIR带通滤波器[以下代码是故意惯用的]:

fs = 40e6           # 40 MHz f sample frequency
fc = 1e6/fs         # 1 MHz center cutoff
BW = 20e3/fs        # 20 kHz bandwidth 
fl = (fc - BW/2)/fs # 0.99 MHz f lower cutoff
fh = (fc + BW/2)/fs # 1.01 MHz f higher cutoff
Run Code Online (Sandbox Code Playgroud)

给出系数:

R  = 1 - (3*BW)
K  = (1 - 2*R*np.cos(2*np.pi*fc) + (R*R)) / (2 - 2*np.cos(2*np.pi*fc))

a0 = 1 - K                       # a0 =  0.00140
a1 = 2*(K-R)*np.cos(2*np.pi*fc)  # …
Run Code Online (Sandbox Code Playgroud)

python response filter

6
推荐指数
1
解决办法
3784
查看次数

paw:将响应字段复制到环境中

使用Paw,我正在访问用于发出身份验证请求的端点.响应通过JSON返回并包含一个sessionId,我需要将其作为变量(SESSION_ID)放入我的环境中.然后,在发送回服务器的所有请求的Authorization标头中使用此环境变量.

有没有办法从身份验证响应中提取sessionId值的脚本并将值放入环境变量中,而不必每次进行身份验证时都执行复制和粘贴?

感谢您的帮助.

javascript response paw

6
推荐指数
1
解决办法
112
查看次数

Angular2 - HTTP 200被视为错误

我想让Angular2与我的Asp.Net WebApi 2服务器一起工作.我设法正确处理了一些GET请求,但是这个POST请求表现得很奇怪.我从服务器收到OK(200)响应,但以下代码将其视为错误:

public Register(){
    this.accountService.Register(this.Name, this.Password, this.RepeatPassword, this.Email, this.Skype, this.Website).subscribe(
        () => {      //this is what's supposed to be called, but isn't
            this.accountService.Login(this.Name, this.Password).subscribe(
                res => {
                    console.log(res);
                    localStorage.setItem('token', res);
                    localStorage.setItem('user', this.Name);
                    this.router.navigate(['Home']);
                },
                error2 => {
                    console.log(error2.Message);
                }
            );
        },
        error => { //the response gets here, instead of being handled above
            console.log(error.Message);
        }
    );
}
Run Code Online (Sandbox Code Playgroud)

这是accountService的Register方法:

public Register (userName:string, password:string, confirmPassword:string, email:string, skype:string, website:string)
{
    return this.http.post(this.Uri + 'api/Account/Register', JSON.stringify(
        {
            UserName: userName,
            Password: password,
            ConfirmPassword: confirmPassword, …
Run Code Online (Sandbox Code Playgroud)

ajax http response angularjs asp.net-web-api2

6
推荐指数
1
解决办法
3610
查看次数

如果Content-Type是application/json,那么空体是否正确?

如果端点'/ tokens/verify'的令牌错误,我返回状态码401,并且不需要向用户发送任何正文内容.

application/json内容类型发送空体是否正确?

json http response request

6
推荐指数
1
解决办法
3336
查看次数