解:先化简原式:
$ \begin{aligned}&(\frac{1}{x+1}+x-1)÷\frac{x^2}{x^2+2x+1}\\=&\frac{1+(x-1)(x+1)}{x+1}·\frac{(x+1)^2}{x^2}\\=&\frac{x^2}{x+1}·\frac{(x+1)^2}{x^2}\\ =&x+1 \end{aligned} $
由$x^2-2x-3=0,$移项得$x^2-2x=3,$
配方得$x^2-2x+1=4,$即$(x-1)^2=4,$
开平方得$x-1=\pm2,$
解得$x_1=3,$$x_2=-1。$
根据分式的分母不能为0,得$x≠0$且$x≠-1,$
$\therefore x=3,$此时原式$=3+1=4。$