c# - finding session state tag in web.config -


i need write function, have find session state tag/setting in web.config of application.

i passing web.config file parameter function , function should detect tag , delete it, should return web.config without session state tag in it.

can have functionality or regex achieve this?

session tag format:

<sessionstate mode="stateserver" stateconnectionstring="tcpip=ctsintcovocprd4:42424" /> 

or

<sessionstate mode="stateserver" stateconnectionstring="tcpip=ctsintcovocprd4:42424"></sessionstate> 

this example extract viewstate, can modify pull session state.

html = regex.replace(html, "<div\\s*class=\"aspnethidden\"[\\s\\s]*?<\\/div\\>", string.empty, regexoptions.ignorecase); 

this regex session state :

regex (tested on regexhere.net)

<sessionstate\s*mode=\"stateserver"\s*stateconnectionstring=\"tcpip=([^"]+)"\s*\/> 

input

<sessionstate mode="stateserver" stateconnectionstring="tcpip=ctsintcovocprd4:42424" /> 

you can make function read webconfig , replace state string using regex.replace [not tested personally]


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -