---
title: mainDocumentURL
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsmutableurlrequest/maindocumenturl
---

# mainDocumentURL

The main document URL.

## Declaration

```swift
var mainDocumentURL: URL? { get set }
```

## Discussion

Discussion The caller should set the main document URL to an appropriate main document, if known. For example, when loading a web page the URL of the HTML document for the top-level frame would be appropriate. This URL will be used for the “only from same domain as main document” cookie accept policy. nil indicates no main document.

## See Also

### Accessing request components

- [httpMethod](foundation/nsmutableurlrequest/httpmethod.md)
- [url](foundation/nsmutableurlrequest/url.md)
- [httpBody](foundation/nsmutableurlrequest/httpbody.md)
- [httpBodyStream](foundation/nsmutableurlrequest/httpbodystream.md)
