It could be a bad switch but it's possible that the flame safety sensor is bad. When you turn the knob the gas valve opens and you should get a flame. The safety sensor senses a flame and allows the gas valve to remain open. If the sensor does not sense flame within 10 secs or so than it will shutdown the gas control valve. If you get a brief flame that goes out after a few seconds than the safety sensor is either dirty or bad. The sensor is within 2-3 inches of the burner orifice and should be in contact with the flame. Most resemble a short metal rod with a thickness slightly larger than a metal coat hanger.
Answers & Comments
It could be a bad switch but it's possible that the flame safety sensor is bad. When you turn the knob the gas valve opens and you should get a flame. The safety sensor senses a flame and allows the gas valve to remain open. If the sensor does not sense flame within 10 secs or so than it will shutdown the gas control valve. If you get a brief flame that goes out after a few seconds than the safety sensor is either dirty or bad. The sensor is within 2-3 inches of the burner orifice and should be in contact with the flame. Most resemble a short metal rod with a thickness slightly larger than a metal coat hanger.