# Passing data withHeader

**URL:** https://discourse.slimframework.com/t/passing-data-withheader/4243
**Category:** Questions
**Created:** [June 22, 2020, 4:23pm UTC](https://discourse.slimframework.com/t/passing-data-withheader/4243 "2020-06-22T16:23:45Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![sim](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@sim](https://discourse.slimframework.com/u/sim)
#### Post date: [June 22, 2020, 4:23pm UTC](https://discourse.slimframework.com/t/passing-data-withheader/4243/1 "2020-06-22T16:23:45Z")

</div>

Hello

I want to make a redirect in my Controller:

`return $response->withHeader('Location', 'dashboard'])->withStatus(302);`

But I want to pass some data to the view. But something like this doesn’t work:

```
return $response->withHeader('Location', 'dashboard', [
      'foo' = $foo
    ])->withStatus(302);

```

Can someone please help me?

---

<div class="post-metadata">

### Author: ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)
#### Post date: [June 22, 2020, 7:21pm UTC](https://discourse.slimframework.com/t/passing-data-withheader/4243/2 "2020-06-22T19:21:43Z")

</div>

Does your ‘dashboard’ route have a [name](http://www.slimframework.com/docs/v4/objects/routing.html#route-names)?

You can generate a URL for this named route with the application RouteParser’s `urlFor()` method.

```php
$app->get('/dashboard', function ($request, $response, $args) {
    $response->getBody()->write("Hello dashboard!");
    return $response;
})->setName('dashboard');

```

Usage:

```auto
$routeParser = \Slim\Routing\RouteContext::fromRequest($request)->getRouteParser();

// Outputs "/dashboard?foo=bar"
$url = $routeParser->urlFor('dashboard', ['foo' => 'bar']);

return $response->withHeader('Location', $url)->withStatus(302);

```
